40std::unique_ptr<HyperGraphActionLibrary>
57 : _typeName(typeName_) {}
77 const std::string& name_) {
84 ActionMap::iterator it =
_actionMap.find(
typeid(*element).name());
87 return (*action)(element, params);
93 ActionMap::iterator it =
_actionMap.find(
typeid(*element).name());
96 return (*action)(element, params);
101#ifdef G2O_DEBUG_ACTIONLIB
105 if (action->name() !=
name()) {
107 "{}: invalid attempt to register an action in a collection with a "
108 "different name {} {}",
111 _actionMap.insert(make_pair(action->typeName(), action));
117 for (HyperGraphElementAction::ActionMap::iterator it =
_actionMap.begin();
119 if (it->second == action) {
136 std::unique_ptr<HyperGraphActionLibrary> aux;
141 const std::string& name) {
142 HyperGraphElementAction::ActionMap::iterator it =
_actionMap.find(name);
143 if (it !=
_actionMap.end())
return it->second.get();
155 "{}: : fatal error, a collection is not at the first level in the "
164#ifdef G2O_DEBUG_ACTIONLIB
177 list<HyperGraphElementActionCollection*> collectionDeleteList;
183 for (HyperGraphElementAction::ActionMap::iterator it =
_actionMap.begin();
187 if (collection !=
nullptr) {
189 if (collection->
actionMap().size() == 0) {
190 collectionDeleteList.push_back(collection);
196 for (list<HyperGraphElementActionCollection*>::iterator itc =
197 collectionDeleteList.begin();
198 itc != collectionDeleteList.end(); ++itc) {
208 _name =
"writeGnuplot";
245 for (CacheContainer::iterator it = caches->begin(); it != caches->end();
247 Cache* c = it->second;
248 (*_cacheDrawActions)(c, params_);
256 (*_cacheDrawActions)(data, params_);
263 const std::string& typeName) {
264 for (HyperGraph::VertexIDMap::iterator it = graph->
vertices().begin();
265 it != graph->
vertices().end(); ++it) {
266 auto& aux = *it->second;
267 if (typeName.empty() ||
typeid(aux).name() == typeName) {
268 (*action)(it->second, params);
271 for (HyperGraph::EdgeSet::iterator it = graph->
edges().begin();
272 it != graph->
edges().end(); ++it) {
274 if (typeName.empty() ||
typeid(aux).name() == typeName)
275 (*action)(*it, params);
void initializeDrawActionsCache()
HyperGraphElementAction * _cacheDrawActions
void drawCache(CacheContainer *caches, HyperGraphElementAction::Parameters *params_)
DrawAction(const std::string &typeName_)
void drawUserData(HyperGraph::Data *data, HyperGraphElementAction::Parameters *params_)
virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters *params_)
Parameters * _previousParams
library of actions, indexed by the action name;
bool registerAction(const HyperGraphElementAction::HyperGraphElementActionPtr &action)
static HyperGraphActionLibrary * instance()
return the single instance of the HyperGraphActionLibrary
static void destroy()
free the instance
HyperGraphElementAction * actionByName(const std::string &name)
static std::unique_ptr< HyperGraphActionLibrary > actionLibInstance
bool unregisterAction(const HyperGraphElementAction::HyperGraphElementActionPtr &action)
HyperGraphElementAction::ActionMap _actionMap
ParametersIteration(int iter)
Abstract action that operates on an entire graph.
virtual ~HyperGraphAction()
virtual HyperGraphAction * operator()(const HyperGraph *graph, Parameters *parameters=0)
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, Parameters *parameters)
bool registerAction(const HyperGraphElementAction::HyperGraphElementActionPtr &action)
HyperGraphElementActionCollection(const std::string &name_)
constructor. name_ is the name of the action e.g.draw).
bool unregisterAction(const HyperGraphElementAction::HyperGraphElementActionPtr &action)
Abstract action that operates on a graph entity.
virtual ~HyperGraphElementAction()
HyperGraphElementAction(const std::string &typeName_="")
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, Parameters *parameters)
const std::string & name() const
returns the name of an action, e.g "draw"
std::shared_ptr< HyperGraphElementAction > HyperGraphElementActionPtr
void setTypeName(const std::string &typeName_)
sets the type on which an action has to operate
data packet for a vertex. Extend this class to store in the vertices the potential additional informa...
const EdgeSet & edges() const
const VertexIDMap & vertices() const
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
WriteGnuplotAction(const std::string &typeName_)
#define __PRETTY_FUNCTION__
void applyAction(HyperGraph *graph, HyperGraphElementAction *action, HyperGraphElementAction::Parameters *params, const std::string &typeName)