/* * PanelPlotNodeRegistry.hh * * Created on: Dec 6, 2013 * Author: amdadev */ #ifndef PANELPLOTNODETREGISTRY_HH_ #define PANELPLOTNODETREGISTRY_HH_ #include <map> #include <memory> #include <mutex> #include <string> #include "AbstractPanelPlotNode.hh" #include "AbstractPlotConfigNode.hh" namespace plot { class PanelPlotNodeRegistry { public: /** * singleton creation */ static PanelPlotNodeRegistry& getInstance(){ return _Instance; } virtual ~PanelPlotNodeRegistry(); /** * Registers a post-processing. */ std::string addElement(const std::string&, boost::shared_ptr<AbstractPanelPlotNode>); /** * Gets all registered post-processing. */ std::map<const std::string, boost::shared_ptr<AbstractPanelPlotNode>> getAllElements() { return getRegistry(); } /** * Registers a plot config node. */ std::string addConfigElement(const std::string&, boost::shared_ptr<AbstractPlotConfigNode>); /** * Gets all registered post-processing. */ std::map<const std::string, boost::shared_ptr<AbstractPlotConfigNode>> getConfigurationNodes() { return getConfigRegistry(); } protected: /** * Access the plot-panel registry and guaranty it is created at the first access. */ static std::map<const std::string, boost::shared_ptr<AbstractPanelPlotNode>>& getRegistry() { // static local field is created once and returned each time function is called.(C++ strange behavior !!! ) static std::map<const std::string, boost::shared_ptr<AbstractPanelPlotNode>> _panelPlotOutputMap = std::map<const std::string, boost::shared_ptr<AbstractPanelPlotNode>>(); return _panelPlotOutputMap; } /** * Access the default plot configuration registry and guaranty it is created at the first access. */ static std::map<const std::string, boost::shared_ptr<AbstractPlotConfigNode>>& getConfigRegistry() { // static local field is created once and returned each time function is called. static std::map<const std::string, boost::shared_ptr<AbstractPlotConfigNode>> _defaultPlotConfigNodeMap = std::map<const std::string, boost::shared_ptr<AbstractPlotConfigNode>>(); return _defaultPlotConfigNodeMap; } private: /** * instance can only created using getInstance() method. */ PanelPlotNodeRegistry(); /** * Singleton unique instance */ static PanelPlotNodeRegistry _Instance; }; } /* namespace plot */ #endif /* PANELPLOTNODETREGISTRY_HH_ */