25 void Entity::entityRegistration() {
26 PoolStorage::getInstance()->registerEntity(
name,
this);
29 void Entity::entityDeregistration() {
30 PoolStorage::getInstance()->deregisterEntity(
name);
33 Entity::Entity(
const string &name__) :
name(name__) {
34 dgDEBUG(15) <<
"New entity <" << name__ <<
">" << endl;
35 if (
name.length() == 0) {
49 for (std::map<const std::string, Command *>::iterator it =
commandMap.begin();
60 for (
unsigned int i = 0; i < signals.
getSize(); ++i) {
63 istringstream iss(sig.
getName());
64 const int SIZE = 4096;
67 iss.getline(buffer, SIZE,
':');
69 const string &signame(buffer);
71 SignalMap::iterator sigkey =
signalMap.find(signame);
74 dgERRORF(
"Key %s already exist in the signalMap.", signame.c_str());
75 if (sigkey->second != &sig) {
78 "Another signal already defined with the same name. ",
79 "Signame is <%s>.", signame.c_str());
82 dgDEBUG(10) <<
"Register signal <" << signame <<
"> for entity <" 90 SignalMap::iterator sigkey =
signalMap.find(signame);
93 dgERRORF(
"Key %s does not exist in the signalMap.", signame.c_str());
95 "No signal defined with the given name. ",
96 " (while erasing <%s>).", signame.c_str());
98 dgDEBUG(10) <<
"Deregister signal <" << signame <<
"> for entity <" 105 std::string docString(
"No header documentation.");
109 #define __DG_ENTITY_GET_SIGNAL__(ITER_TYPE) \ 110 SignalMap::ITER_TYPE sigkey = signalMap.find(signame); \ 111 if (sigkey == signalMap.end()) \ 113 throw ExceptionFactory(ExceptionFactory::UNREFERED_SIGNAL, \ 114 "The requested signal is not registered", ": %s", \ 117 return *(sigkey->second); 132 os <<
"--- <" <<
getName() <<
"> signal list: " << endl;
133 const SignalMap::const_iterator iterend =
signalMap.end();
134 for (SignalMap::const_iterator iter =
signalMap.begin(); iterend != iter;
137 if ((++iter)-- == iterend)
141 os <<
"-- <" << *(iter->second) << endl;
147 const SignalMap::const_iterator iterend =
signalMap.end();
148 for (SignalMap::const_iterator iter =
signalMap.begin(); iterend != iter;
150 (*(iter->second)).writeGraph(os);
156 const SignalMap::const_iterator iterend =
signalMap.end();
157 for (SignalMap::const_iterator iter =
signalMap.begin(); iterend != iter;
159 os <<
getName() <<
"." << (*(iter->second)).shortName() << std::endl;
191 "Command " + inName +
" already registered in Entity.");
193 std::pair<const std::string, Command *> item(inName, command);
206 "Command <" + commandName +
"> is not registered in Entity.");
212 const std::string &lineId) {
const std::string & getCommandList() const
std::ostream & displaySignalList(std::ostream &os) const
Display the list of signals of this entity in output stream os.
virtual std::string getDocString() const
Returns the Entity documentation.
#define __DG_ENTITY_GET_SIGNAL__(ITER_TYPE)
bool hasSignal(const std::string &signame) const
Test if a signal of name signame is present.
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
#define dgDEBUGOUT(level)
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
Send messages msg with level t. Add string file and line to message.
void signalRegistration(const SignalArray< int > &signals)
SignalMap getSignalMap() const
Provides a map of all the signals.
virtual std::ostream & writeGraph(std::ostream &os) const
This method is used to write down in os the edges of the graph by calling the signals writeGraph meth...
command::Command * getNewStyleCommand(const std::string &cmdName)
Provides the pointer towards the Command object cmdName.
std::map< std::string, SignalBase< int > * > SignalMap
dynamicgraph::SignalArray_const< double > sig
virtual const std::string & getClassName() const
const std::string & getName() const
void dgERRORF(const int, const char *,...)
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
virtual std::ostream & writeCompletionList(std::ostream &os) const
This method is used write in the output stream os the signals names and the commands of the entity...
virtual unsigned int getSize() const
virtual void display(std::ostream &os) const
Display information on the entity inside the output stream os.
CommandMap_t getNewStyleCommandMap()
Provides the std::map where all the commands are registered.
static std::string Entity_COMMAND_LIST
const std::string & getName() const
SignalBase< int > & getSignal(const std::string &signalName)
Provides a reference to the signal named signalName.
void entityRegistration()
void signalDeregistration(const std::string &name)
void addCommand(const std::string &name, command::Command *command)
Add a command to Entity.