include/dynamic-graph/entity.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
3 // JRL, CNRS/AIST.
4 //
5 
6 #ifndef DYNAMIC_GRAPH_ENTITY_H
7 #define DYNAMIC_GRAPH_ENTITY_H
10 #include <dynamic-graph/logger.h>
13 
14 #include <boost/noncopyable.hpp>
15 #include <dynamic-graph/fwd.hh>
16 #include <iosfwd>
17 #include <map>
18 #include <sstream>
19 #include <string>
20 
31 // // your class here
38 #define DYNAMIC_GRAPH_ENTITY_DECL() \
39  public: \
40  virtual const std::string &getClassName() const { return CLASS_NAME; } \
41  static const std::string CLASS_NAME
42 
43 namespace dynamicgraph {
52 class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable {
53  public:
54  typedef std::map<std::string, SignalBase<sigtime_t> *> SignalMap;
55  typedef std::map<const std::string, command::Command *> CommandMap_t;
56 
57  explicit Entity(const std::string &name);
58  virtual ~Entity();
59 
60  const std::string &getName() const { return name; }
61  virtual const std::string &getClassName() const {
62  static std::string ret("Entity");
63  return ret;
64  }
68  virtual std::string getDocString() const;
69 
73  bool hasSignal(const std::string &signame) const;
74 
79  SignalBase<sigtime_t> &getSignal(const std::string &signalName);
80 
85  const SignalBase<sigtime_t> &getSignal(const std::string &signalName) const;
86 
91  std::ostream &displaySignalList(std::ostream &os) const;
92 
98  virtual std::ostream &writeGraph(std::ostream &os) const;
99 
105  virtual std::ostream &writeCompletionList(std::ostream &os) const;
106 
109  virtual void display(std::ostream &os) const;
110 
111  virtual SignalBase<sigtime_t> *test() { return 0; }
112 
113  virtual void test2(SignalBase<sigtime_t> *) { return; }
114 
115  const std::string &getCommandList() const;
116 
120  CommandMap_t getNewStyleCommandMap();
124  command::Command *getNewStyleCommand(const std::string &cmdName);
125 
130  SignalMap getSignalMap() const;
131 
134 
135  Logger &logger() { return logger_; };
136  Logger const &logger() const { return logger_; };
137 
140  void sendMsg(const std::string &msg, MsgType t = MSG_TYPE_INFO,
141  const std::string &lineId = "");
142 
144  void setLoggerVerbosityLevel(LoggerVerbosity lv) { logger_.setVerbosity(lv); }
145 
147  LoggerVerbosity getLoggerVerbosityLevel() { return logger_.getVerbosity(); }
148 
150  bool setTimeSample(double t) { return logger_.setTimeSample(t); }
151 
153  double getTimeSample() { return logger_.getTimeSample(); }
154 
156  bool setStreamPrintPeriod(double t) {
157  return logger_.setStreamPrintPeriod(t);
158  }
159 
161  double getStreamPrintPeriod() { return logger_.getStreamPrintPeriod(); }
162 
164 
165  protected:
166  void addCommand(const std::string &name, command::Command *command);
167 
168  void entityRegistration();
169  void entityDeregistration();
170 
171  void signalRegistration(const SignalArray<sigtime_t> &signals);
172  void signalDeregistration(const std::string &name);
173 
174  std::string name;
178 };
179 
180 DYNAMIC_GRAPH_DLLAPI std::ostream &operator<<(std::ostream &os,
181  const dynamicgraph::Entity &ent);
182 } // end of namespace dynamicgraph
183 
184 #endif
signal-array.h
dynamicgraph::operator<<
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
Definition: src/dgraph/entity.cpp:174
dynamicgraph::Entity::logger
Logger & logger()
Definition: include/dynamic-graph/entity.h:135
dynamicgraph::Entity::logger
const Logger & logger() const
Definition: include/dynamic-graph/entity.h:136
dynamicgraph::Logger
Class for logging messages.
Definition: logger.h:186
logger.h
dynamicgraph::LoggerVerbosity
LoggerVerbosity
Definition: logger.h:143
dynamic-graph-api.h
dynamicgraph
dynamicgraph::Entity::commandMap
CommandMap_t commandMap
Definition: include/dynamic-graph/entity.h:176
dynamicgraph::Entity
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: include/dynamic-graph/entity.h:52
dynamicgraph::Entity::setStreamPrintPeriod
bool setStreamPrintPeriod(double t)
Set the period of the stream period.
Definition: include/dynamic-graph/entity.h:156
dynamicgraph::Entity::name
std::string name
Definition: include/dynamic-graph/entity.h:174
dynamicgraph::MSG_TYPE_INFO
@ MSG_TYPE_INFO
Definition: logger.h:34
dynamicgraph::Entity::SignalMap
std::map< std::string, SignalBase< sigtime_t > * > SignalMap
Definition: include/dynamic-graph/entity.h:54
dynamicgraph::Entity::getName
const std::string & getName() const
Definition: include/dynamic-graph/entity.h:60
fwd.hh
signal-base.h
dynamicgraph::Entity::setTimeSample
bool setTimeSample(double t)
Set the time sample.
Definition: include/dynamic-graph/entity.h:150
dynamicgraph::Entity::CommandMap_t
std::map< const std::string, command::Command * > CommandMap_t
Definition: include/dynamic-graph/entity.h:55
dynamicgraph::command::Command
Definition: command.h:35
dynamicgraph::Entity::getClassName
virtual const std::string & getClassName() const
Definition: include/dynamic-graph/entity.h:61
dynamicgraph::Entity::test
virtual SignalBase< sigtime_t > * test()
Definition: include/dynamic-graph/entity.h:111
dynamicgraph::Entity::logger_
Logger logger_
Definition: include/dynamic-graph/entity.h:177
exception-factory.h
dynamicgraph::MsgType
MsgType
Definition: logger.h:29
dynamicgraph::Entity::getTimeSample
double getTimeSample()
Get the time sample.
Definition: include/dynamic-graph/entity.h:153
dynamicgraph::SignalArray
TODO.
Definition: fwd.hh:47
dynamicgraph::Entity::getStreamPrintPeriod
double getStreamPrintPeriod()
Get the period of the stream period.
Definition: include/dynamic-graph/entity.h:161
dynamicgraph::Entity::test2
virtual void test2(SignalBase< sigtime_t > *)
Definition: include/dynamic-graph/entity.h:113
dynamicgraph::SignalBase< sigtime_t >
dynamicgraph::Entity::signalMap
SignalMap signalMap
Definition: include/dynamic-graph/entity.h:175
compile.name
name
Definition: compile.py:23
dynamicgraph::Entity::setLoggerVerbosityLevel
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
Definition: include/dynamic-graph/entity.h:144
dynamicgraph::Entity::getLoggerVerbosityLevel
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger's verbosity level.
Definition: include/dynamic-graph/entity.h:147


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38