dynamic-graph  4.1.0-8-gdab7-dirty
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 <iosfwd>
9 #include <map>
10 #include <sstream>
11 #include <string>
12 
13 #include <boost/noncopyable.hpp>
14 
15 #include <dynamic-graph/dynamic-graph-api.h>
16 #include <dynamic-graph/exception-factory.h>
17 #include <dynamic-graph/fwd.hh>
18 #include <dynamic-graph/logger.h>
19 #include <dynamic-graph/signal-array.h>
20 #include <dynamic-graph/signal-base.h>
21 
32 // // your class here
39 #define DYNAMIC_GRAPH_ENTITY_DECL() \
40 public: \
41  virtual const std::string &getClassName() const { return CLASS_NAME; } \
42  static const std::string CLASS_NAME
43 
44 namespace dynamicgraph {
53 class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable {
54 public:
55  typedef std::map<std::string, SignalBase<int> *> SignalMap;
56  typedef std::map<const std::string, command::Command *> CommandMap_t;
57 
58  explicit Entity(const std::string &name);
59  virtual ~Entity();
60 
61  const std::string &getName() const { return name; }
62  virtual const std::string &getClassName() const {
63  static std::string ret("Entity");
64  return ret;
65  }
69  virtual std::string getDocString() const;
70 
74  bool hasSignal(const std::string &signame) const;
75 
80  SignalBase<int> &getSignal(const std::string &signalName);
81 
86  const SignalBase<int> &getSignal(const std::string &signalName) const;
87 
92  std::ostream &displaySignalList(std::ostream &os) const;
93 
99  virtual std::ostream &writeGraph(std::ostream &os) const;
100 
106  virtual std::ostream &writeCompletionList(std::ostream &os) const;
107 
110  virtual void display(std::ostream &os) const;
111 
112  virtual SignalBase<int> *test() { return 0; }
113 
114  virtual void test2(SignalBase<int> *) { return; }
115 
116  const std::string &getCommandList() const;
117 
121  CommandMap_t getNewStyleCommandMap();
125  command::Command *getNewStyleCommand(const std::string &cmdName);
126 
131  SignalMap getSignalMap() const;
132 
135 
136  Logger &logger() { return logger_; };
137  Logger const &logger() const { return logger_; };
138 
141  void sendMsg(const std::string &msg, MsgType t = MSG_TYPE_INFO,
142  const std::string &lineId = "");
143 
145  void setLoggerVerbosityLevel(LoggerVerbosity lv) { logger_.setVerbosity(lv); }
146 
148  LoggerVerbosity getLoggerVerbosityLevel() { return logger_.getVerbosity(); }
149 
151  bool setTimeSample(double t) { return logger_.setTimeSample(t); }
152 
154  double getTimeSample() { return logger_.getTimeSample(); }
155 
157  bool setStreamPrintPeriod(double t) {
158  return logger_.setStreamPrintPeriod(t);
159  }
160 
162  double getStreamPrintPeriod() { return logger_.getStreamPrintPeriod(); }
163 
165 
166 protected:
167  void addCommand(const std::string &name, command::Command *command);
168 
169  void entityRegistration();
170  void entityDeregistration();
171 
172  void signalRegistration(const SignalArray<int> &signals);
173  void signalDeregistration(const std::string &name);
174 
175  std::string name;
176  SignalMap signalMap;
177  CommandMap_t commandMap;
178  Logger logger_;
179 };
180 
181 DYNAMIC_GRAPH_DLLAPI std::ostream &operator<<(std::ostream &os,
182  const dynamicgraph::Entity &ent);
183 } // end of namespace dynamicgraph
184 
185 #endif
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: entity.h:53
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger&#39;s verbosity level.
Definition: entity.h:148
bool setStreamPrintPeriod(double t)
Set the period of the stream period.
Definition: entity.h:157
double getStreamPrintPeriod()
Get the period of the stream period.
Definition: entity.h:162
bool setTimeSample(double t)
Set the time sample.
Definition: entity.h:151
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
Definition: entity.h:145
Class for logging messages.
Definition: logger.h:187
double getTimeSample()
Get the time sample.
Definition: entity.h:154