65 _typeName = typeName_;
70 _typeName = typeName_;
95 for (ActionMap::iterator it = _actionMap.begin(); it != _actionMap.end(); ++it) {
102 ActionMap::iterator it=_actionMap.find(
typeid(*element).name());
104 if (it==_actionMap.end())
107 return (*action)(element, params);
112 ActionMap::iterator it=_actionMap.find(
typeid(*element).name());
113 if (it==_actionMap.end())
116 return (*action)(element, params);
121 # ifdef G2O_DEBUG_ACTIONLIB 124 if (action->
name()!=name()){
125 cerr <<
__PRETTY_FUNCTION__ <<
": invalid attempt to register an action in a collection with a different name " << name() <<
" " << action->
name() << endl;
127 _actionMap.insert(make_pair ( action->
typeName(), action) );
133 for (HyperGraphElementAction::ActionMap::iterator it=_actionMap.begin(); it != _actionMap.end(); ++it) {
134 if (it->second == action){
135 _actionMap.erase(it);
148 if (actionLibInstance == 0) {
151 return actionLibInstance;
156 delete actionLibInstance;
157 actionLibInstance = 0;
162 for (HyperGraphElementAction::ActionMap::iterator it = _actionMap.begin(); it != _actionMap.end(); ++it) {
169 HyperGraphElementAction::ActionMap::iterator it=_actionMap.find(name);
170 if (it!=_actionMap.end())
182 cerr <<
__PRETTY_FUNCTION__ <<
": fatal error, a collection is not at the first level in the library" << endl;
187 #ifdef G2O_DEBUG_ACTIONLIB 191 _actionMap.insert(make_pair(action->
name(), collection));
198 list<HyperGraphElementActionCollection*> collectionDeleteList;
201 for (HyperGraphElementAction::ActionMap::iterator it=_actionMap.begin(); it != _actionMap.end(); ++it) {
203 if (collection != 0) {
205 if (collection->
actionMap().size() == 0) {
206 collectionDeleteList.push_back(collection);
212 for (list<HyperGraphElementActionCollection*>::iterator itc = collectionDeleteList.begin(); itc != collectionDeleteList.end(); ++itc) {
214 _actionMap.erase((*itc)->name());
224 _name=
"writeGnuplot";
263 for (CacheContainer::iterator it=caches->begin(); it!=caches->end(); it++){
264 Cache* c = it->second;
265 (*_cacheDrawActions)(c, params_);
272 (*_cacheDrawActions)(data, params_);
279 for (HyperGraph::VertexIDMap::iterator it=graph->
vertices().begin();
281 if ( typeName.empty() ||
typeid(*it->second).
name()==
typeName){
282 (*action)(it->second, params);
285 for (HyperGraph::EdgeSet::iterator it=graph->
edges().begin();
286 it!=graph->
edges().end(); ++it){
287 if ( typeName.empty() ||
typeid(**it).name()==
typeName)
288 (*action)(*it, params);
DrawAction(const std::string &typeName_)
#define __PRETTY_FUNCTION__
data packet for a vertex. Extend this class to store in the vertices the potential additional informa...
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, Parameters *parameters)
redefine this to do the action stuff. If successful, the action returns a pointer to itself ...
bool registerAction(HyperGraphElementAction *action)
Abstract action that operates on a graph entity.
Parameters * _previousParams
static void destroy()
free the instance
void applyAction(HyperGraph *graph, HyperGraphElementAction *action, HyperGraphElementAction::Parameters *params, const std::string &typeName)
ParametersIteration(int iter)
HyperGraphElementActionCollection(const std::string &name_)
constructor. name_ is the name of the action e.g.draw).
const VertexIDMap & vertices() const
bool unregisterAction(HyperGraphElementAction *action)
const std::string & name() const
returns the name of an action, e.g "draw"
HyperGraphElementAction * _cacheDrawActions
void setTypeName(const std::string &typeName_)
sets the type on which an action has to operate
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
virtual ~HyperGraphElementActionCollection()
destructor: it deletes all actions in the pool.
void drawCache(CacheContainer *caches, HyperGraphElementAction::Parameters *params_)
const EdgeSet & edges() const
static HyperGraphActionLibrary * instance()
return the single instance of the HyperGraphActionLibrary
bool registerAction(HyperGraphElementAction *action)
HyperGraphElementAction * actionByName(const std::string &name)
void drawUserData(HyperGraph::Data *data, HyperGraphElementAction::Parameters *params_)
void initializeDrawActionsCache()
WriteGnuplotAction(const std::string &typeName_)
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, Parameters *parameters)
HyperGraphElementAction(const std::string &typeName_="")
virtual ~HyperGraphAction()
const std::string & typeName() const
returns the typeid name of the action
virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters *params_)
~HyperGraphActionLibrary()
static HyperGraphActionLibrary * actionLibInstance
bool unregisterAction(HyperGraphElementAction *action)
HyperGraphActionLibrary()
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the graph
virtual ~HyperGraphElementAction()
destroyed actions release the memory
Abstract action that operates on an entire graph.
library of actions, indexed by the action name;
virtual HyperGraphAction * operator()(const HyperGraph *graph, Parameters *parameters=0)