dynamic-graph  4.4.3
Dynamic graph library
entity.h
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
8 #include <dynamic-graph/dynamic-graph-api.h>
9 #include <dynamic-graph/exception-factory.h>
10 #include <dynamic-graph/logger.h>
11 #include <dynamic-graph/signal-array.h>
12 #include <dynamic-graph/signal-base.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<int> *> 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<int> &getSignal(const std::string &signalName);
80 
85  const SignalBase<int> &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<int> *test() { return 0; }
112 
113  virtual void test2(SignalBase<int> *) { 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<int> &signals);
172  void signalDeregistration(const std::string &name);
173 
174  std::string name;
175  SignalMap signalMap;
176  CommandMap_t commandMap;
177  Logger logger_;
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
dynamicgraph::Entity::getLoggerVerbosityLevel
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger's verbosity level.
Definition: entity.h:147
dynamicgraph::Logger
Class for logging messages.
Definition: logger.h:186
dynamicgraph::Entity::setLoggerVerbosityLevel
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
Definition: entity.h:144
dynamicgraph
Definition: command-bind.h:30
dynamicgraph::Entity
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: entity.h:52
dynamicgraph::MsgType
MsgType
Definition: logger.h:29
dynamicgraph::Entity::setStreamPrintPeriod
bool setStreamPrintPeriod(double t)
Set the period of the stream period.
Definition: entity.h:156
dynamicgraph::command::Command
Definition: command.h:35
dynamicgraph::Entity::getTimeSample
double getTimeSample()
Get the time sample.
Definition: entity.h:153
dynamicgraph::Entity::getStreamPrintPeriod
double getStreamPrintPeriod()
Get the period of the stream period.
Definition: entity.h:161
dynamicgraph::Entity::setTimeSample
bool setTimeSample(double t)
Set the time sample.
Definition: entity.h:150
dynamicgraph::SignalArray
TODO.
Definition: fwd.hh:45
dynamicgraph::SignalBase
The base class for signals: not to be used as such.
Definition: fwd.hh:51