Blame view

src/ParamOutputImpl/Plot/PanelPlotNodeRegistry.hh 2.37 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * 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_ */