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<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;
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
virtual void test2(SignalBase< int > *)
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
bool setTimeSample(double t)
Set the time sample.
std::map< std::string, SignalBase< int > * > SignalMap
virtual SignalBase< int > * test()
virtual const std::string & getClassName() const
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
double getTimeSample()
Get the time sample.
double getStreamPrintPeriod()
Get the period of the stream period.
void setLoggerVerbosityLevel(LoggerVerbosity lv)
Specify the verbosity level of the logger.
std::map< const std::string, command::Command * > CommandMap_t
LoggerVerbosity getLoggerVerbosityLevel()
Get the logger&#39;s verbosity level.
const std::string & getName() const
bool setStreamPrintPeriod(double t)
Set the period of the stream period.
Class for logging messages.
Definition: logger.h:186


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03