dynamic-graph  4.1.0-8-gdab7-dirty
Dynamic graph library
pool.h
1 // -*- mode: c++ -*-
2 // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
3 // JRL, CNRS/AIST.
4 //
5 
6 #ifndef DYNAMIC_GRAPH_POOL_H
7 #define DYNAMIC_GRAPH_POOL_H
8 #include <map>
9 #include <sstream>
10 #include <string>
11 
12 #include <dynamic-graph/dynamic-graph-api.h>
13 #include <dynamic-graph/exception-factory.h>
14 #include <dynamic-graph/fwd.hh>
15 #include <dynamic-graph/signal-base.h>
16 
17 namespace dynamicgraph {
33 class DYNAMIC_GRAPH_DLLAPI PoolStorage {
34 public:
39  typedef std::map<std::string, Entity *> Entities;
40 
42  static PoolStorage *getInstance();
43 
45  static void destroy();
46 
50  ~PoolStorage();
51 
59  void registerEntity(const std::string &entname, Entity *ent);
60 
64  void deregisterEntity(const std::string &entname);
65 
69  void deregisterEntity(const Entities::iterator &entity);
74  Entity &getEntity(const std::string &name);
75 
77  const Entities &getEntityMap() const;
78 
80  bool existEntity(const std::string &name);
82  bool existEntity(const std::string &name, Entity *&ptr);
83 
87  void clearPlugin(const std::string &name);
90  SignalBase<int> &getSignal(std::istringstream &sigpath);
95 
98  void writeGraph(const std::string &aFileName);
99  void writeCompletionList(std::ostream &os);
100 
101 protected:
107  Entities entityMap;
108 
109 private:
110  PoolStorage() {}
111  static PoolStorage *instance_;
112 };
113 
114 inline PoolStorage &g_pool() { return *PoolStorage::getInstance(); }
115 
116 } // end of namespace dynamicgraph.
117 
118 #endif
Singleton that keeps track of all the entities.
Definition: pool.h:33
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: entity.h:53
Entities entityMap
Set of basic objects of the SoT.
Definition: pool.h:107
std::map< std::string, Entity * > Entities
Sorted set of entities with unique key (name).
Definition: pool.h:39
static PoolStorage * getInstance()
Get unique instance of the class.