hyper_graph_action.h
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // g2o is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HYPER_GRAPH_ACTION_H
00018 #define HYPER_GRAPH_ACTION_H
00019 
00020 #include "hyper_graph.h"
00021 
00022 #include <typeinfo>
00023 #include <iosfwd>
00024 #include <set>
00025 #include <string>
00026 
00027 namespace g2o {
00028 
00032   class HyperGraphAction {
00033     public:
00034       class Parameters {
00035         public:
00036           virtual ~Parameters();
00037       };
00038 
00039       class ParametersIteration : public Parameters {
00040         public:
00041           explicit ParametersIteration(int iter);
00042           int iteration;
00043       };
00044 
00045       virtual ~HyperGraphAction();
00046 
00050       virtual HyperGraphAction* operator()(const HyperGraph* graph, Parameters* parameters = 0);
00051   };
00052 
00056   class HyperGraphElementAction{
00057     public:
00058       struct Parameters{
00059         virtual ~Parameters();
00060       };
00061       typedef std::map<std::string, HyperGraphElementAction*> ActionMap;
00064       HyperGraphElementAction(const std::string& typeName_="");
00065 
00067       virtual HyperGraphElementAction* operator()(HyperGraph::HyperGraphElement* element, Parameters* parameters);
00068 
00070       virtual HyperGraphElementAction* operator()(const HyperGraph::HyperGraphElement* element, Parameters* parameters);
00071 
00073       virtual ~HyperGraphElementAction();
00074 
00076       const std::string& typeName() const { return _typeName;}
00077 
00079       const std::string& name() const{ return _name;}
00080     protected:
00081       std::string _typeName;
00082       std::string _name;
00083   };
00084 
00091   class HyperGraphElementActionCollection: public HyperGraphElementAction{
00092     public:
00094       HyperGraphElementActionCollection(const std::string& name_);
00096       virtual ~HyperGraphElementActionCollection();
00099       virtual HyperGraphElementAction* operator()(HyperGraph::HyperGraphElement* element, Parameters* parameters);
00100       virtual HyperGraphElementAction* operator()(const HyperGraph::HyperGraphElement* element, Parameters* parameters);
00101       ActionMap& actionMap() {return _actionMap;}
00104       bool registerAction(HyperGraphElementAction* action);
00105     protected:
00106       ActionMap _actionMap;
00107   };
00108 
00115   class HyperGraphActionLibrary{
00116     public:
00118       static HyperGraphActionLibrary* instance();
00120       static void destroy();
00121 
00122       // returns a pointer to a collection indexed by name
00123       HyperGraphElementAction* actionByName(const std::string& name);
00124       // registers a basic action in the pool. If necessary a container is created
00125       bool registerAction(HyperGraphElementAction* action);
00126       inline HyperGraphElementAction::ActionMap& actionMap() {return _actionMap;}
00127     protected:
00128       HyperGraphActionLibrary();
00129       ~HyperGraphActionLibrary();
00130       HyperGraphElementAction::ActionMap _actionMap;
00131     private:
00132       static HyperGraphActionLibrary* actionLibInstance;
00133   };
00134 
00138   void applyAction(HyperGraph* graph, HyperGraphElementAction* action, HyperGraphElementAction::Parameters* parameters=0, const std::string& typeName="");
00139 
00143   class WriteGnuplotAction: public HyperGraphElementAction{
00144     public:
00145       struct Parameters: public HyperGraphElementAction::Parameters{
00146         std::ostream* os;
00147       };
00148       WriteGnuplotAction(const std::string& typeName_);
00149   };
00150 
00154   class DrawAction : public HyperGraphElementAction{
00155     public:
00156       DrawAction(const std::string& typeName_);
00157   };
00158   
00159 };
00160 
00161 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:24