Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::EntityManager Class Reference

#include <EntityManager.h>

Public Member Functions

 EntityManager (interfaces::ControlCenter *c)
 
virtual unsigned long addEntity (const std::string &name)
 creates a new entity with the given name and returns its id More...
 
virtual unsigned long addEntity (SimEntity *entity)
 adds an existing entity to its entity map, returning the assigned id More...
 
virtual void addNode (const std::string &entityName, unsigned long nodeId, const std::string &nodeName)
 adds a node and maps the nodeId to the name More...
 
virtual void addMotor (const std::string &entityName, unsigned long motorId, const std::string &motorName)
 adds a motor to the entity and maps the motorId to its name More...
 
virtual void addController (const std::string &entityName, unsigned long controllerId)
 adds a controller id to the controller list More...
 
virtual void addJoint (const std::string &entityName, unsigned long jointId, const std::string &jointName)
 adds a joint to the entity and maps the jointId to its name More...
 
virtual const std::map< unsigned long, SimEntity * > * subscribeToEntityCreation (interfaces::EntitySubscriberInterface *newsub)
 returns the entity with the given name More...
 
virtual SimEntitygetEntity (const std::string &name)
 returns the entity with the given name More...
 
virtual SimEntitygetEntity (unsigned long id)
 returns the entity with the given id More...
 
virtual unsigned long getEntityNode (const std::string &entityName, const std::string &nodeName)
 returns the node of the given entity; returns 0 if the entity or the node don't exist More...
 
virtual unsigned long getEntityMotor (const std::string &entityName, const std::string &motorName)
 
virtual std::vector< unsigned long > getEntityControllerList (const std::string &entityName)
 
virtual unsigned long getEntityJoint (const std::string &entityName, const std::string &jointName)
 returns the node of the given entity; returns 0 if the entity or the node don't exist More...
 
virtual void selectEvent (unsigned long id, bool mode)
 
virtual void printEntityNodes (const std::string &entityName)
 
virtual void printEntityMotors (const std::string &entityName)
 
virtual void printEntityControllers (const std::string &entityName)
 
virtual void resetPose ()
 
- Public Member Functions inherited from mars::interfaces::GraphicsEventClient
virtual ~GraphicsEventClient ()
 
- Public Member Functions inherited from mars::interfaces::EntityManagerInterface
virtual ~EntityManagerInterface ()
 

Private Member Functions

void notifySubscribers (SimEntity *entity)
 
unsigned long getNextId ()
 returns the id to be assigned to the next entity More...
 

Private Attributes

std::vector< interfaces::EntitySubscriberInterface * > subscribers
 
interfaces::ControlCentercontrol
 
unsigned long next_entity_id
 the id assigned to the next created entity; use getNextId function More...
 
std::map< unsigned long, SimEntity * > entities
 
utils::Mutex iMutex
 

Detailed Description

Definition at line 53 of file EntityManager.h.

Constructor & Destructor Documentation

◆ EntityManager()

mars::sim::EntityManager::EntityManager ( interfaces::ControlCenter c)

Definition at line 37 of file EntityManager.cpp.

Member Function Documentation

◆ addController()

void mars::sim::EntityManager::addController ( const std::string &  entityName,
unsigned long  controllerId 
)
virtual

adds a controller id to the controller list

Implements mars::interfaces::EntityManagerInterface.

Definition at line 116 of file EntityManager.cpp.

◆ addEntity() [1/2]

unsigned long mars::sim::EntityManager::addEntity ( const std::string &  name)
virtual

creates a new entity with the given name and returns its id

Implements mars::interfaces::EntityManagerInterface.

Definition at line 45 of file EntityManager.cpp.

◆ addEntity() [2/2]

unsigned long mars::sim::EntityManager::addEntity ( SimEntity entity)
virtual

adds an existing entity to its entity map, returning the assigned id

Implements mars::interfaces::EntityManagerInterface.

Definition at line 53 of file EntityManager.cpp.

◆ addJoint()

void mars::sim::EntityManager::addJoint ( const std::string &  entityName,
unsigned long  jointId,
const std::string &  jointName 
)
virtual

adds a joint to the entity and maps the jointId to its name

Implements mars::interfaces::EntityManagerInterface.

Definition at line 103 of file EntityManager.cpp.

◆ addMotor()

void mars::sim::EntityManager::addMotor ( const std::string &  entityName,
unsigned long  motorId,
const std::string &  motorName 
)
virtual

adds a motor to the entity and maps the motorId to its name

Implements mars::interfaces::EntityManagerInterface.

Definition at line 90 of file EntityManager.cpp.

◆ addNode()

void mars::sim::EntityManager::addNode ( const std::string &  entityName,
unsigned long  nodeId,
const std::string &  nodeName 
)
virtual

adds a node and maps the nodeId to the name

Implements mars::interfaces::EntityManagerInterface.

Definition at line 73 of file EntityManager.cpp.

◆ getEntity() [1/2]

SimEntity * mars::sim::EntityManager::getEntity ( const std::string &  name)
virtual

returns the entity with the given name

Implements mars::interfaces::EntityManagerInterface.

Definition at line 146 of file EntityManager.cpp.

◆ getEntity() [2/2]

virtual SimEntity* mars::sim::EntityManager::getEntity ( unsigned long  id)
virtual

returns the entity with the given id

Implements mars::interfaces::EntityManagerInterface.

◆ getEntityControllerList()

std::vector< unsigned long > mars::sim::EntityManager::getEntityControllerList ( const std::string &  entityName)
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 190 of file EntityManager.cpp.

◆ getEntityJoint()

long unsigned int mars::sim::EntityManager::getEntityJoint ( const std::string &  entityName,
const std::string &  jointName 
)
virtual

returns the node of the given entity; returns 0 if the entity or the node don't exist

Implements mars::interfaces::EntityManagerInterface.

Definition at line 201 of file EntityManager.cpp.

◆ getEntityMotor()

long unsigned int mars::sim::EntityManager::getEntityMotor ( const std::string &  entityName,
const std::string &  motorName 
)
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 178 of file EntityManager.cpp.

◆ getEntityNode()

long unsigned int mars::sim::EntityManager::getEntityNode ( const std::string &  entityName,
const std::string &  nodeName 
)
virtual

returns the node of the given entity; returns 0 if the entity or the node don't exist

Implements mars::interfaces::EntityManagerInterface.

Definition at line 167 of file EntityManager.cpp.

◆ getNextId()

unsigned long mars::sim::EntityManager::getNextId ( )
inlineprivate

returns the id to be assigned to the next entity

Definition at line 118 of file EntityManager.h.

◆ notifySubscribers()

void mars::sim::EntityManager::notifySubscribers ( SimEntity entity)
private

Definition at line 61 of file EntityManager.cpp.

◆ printEntityControllers()

void mars::sim::EntityManager::printEntityControllers ( const std::string &  entityName)
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 235 of file EntityManager.cpp.

◆ printEntityMotors()

void mars::sim::EntityManager::printEntityMotors ( const std::string &  entityName)
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 224 of file EntityManager.cpp.

◆ printEntityNodes()

void mars::sim::EntityManager::printEntityNodes ( const std::string &  entityName)
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 213 of file EntityManager.cpp.

◆ resetPose()

void mars::sim::EntityManager::resetPose ( )
virtual

Implements mars::interfaces::EntityManagerInterface.

Definition at line 246 of file EntityManager.cpp.

◆ selectEvent()

void mars::sim::EntityManager::selectEvent ( unsigned long  id,
bool  mode 
)
virtual

Implements mars::interfaces::GraphicsEventClient.

Definition at line 129 of file EntityManager.cpp.

◆ subscribeToEntityCreation()

const std::map< unsigned long, SimEntity * > * mars::sim::EntityManager::subscribeToEntityCreation ( interfaces::EntitySubscriberInterface newsub)
virtual

returns the entity with the given name

Implements mars::interfaces::EntityManagerInterface.

Definition at line 68 of file EntityManager.cpp.

Member Data Documentation

◆ control

interfaces::ControlCenter* mars::sim::EntityManager::control
private

Definition at line 112 of file EntityManager.h.

◆ entities

std::map<unsigned long, SimEntity*> mars::sim::EntityManager::entities
private

Definition at line 115 of file EntityManager.h.

◆ iMutex

utils::Mutex mars::sim::EntityManager::iMutex
mutableprivate

Definition at line 123 of file EntityManager.h.

◆ next_entity_id

unsigned long mars::sim::EntityManager::next_entity_id
private

the id assigned to the next created entity; use getNextId function

Definition at line 114 of file EntityManager.h.

◆ subscribers

std::vector<interfaces::EntitySubscriberInterface*> mars::sim::EntityManager::subscribers
private

Definition at line 110 of file EntityManager.h.


The documentation for this class was generated from the following files: