μHAL (v2.6.5)
Part of the IPbus software repository
DerivedNodeFactory.hpp
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 
4  This file is part of uHAL.
5 
6  uHAL is a hardware access library and programming framework
7  originally developed for upgrades of the Level-1 trigger of the CMS
8  experiment at CERN.
9 
10  uHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  uHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Andrew Rose, Imperial College, London
25  email: awr01 <AT> imperial.ac.uk
26 
27  Marc Magrans de Abril, CERN
28  email: marc.magrans.de.abril <AT> cern.ch
29 
30 ---------------------------------------------------------------------------
31 */
32 
40 #ifndef _uhal_DerivedNodeFactory_hpp_
41 #define _uhal_DerivedNodeFactory_hpp_
42 
43 
44 #include <string>
45 
46 #include <boost/noncopyable.hpp>
47 #include <boost/unordered_map.hpp>
48 
49 
50 namespace boost {
51  template <class Y> class shared_ptr;
52 }
53 
54 namespace uhal
55 {
56  class Node;
57  class NodeTreeBuilder; // IWYU pragma: keep
58 
60  template< typename T > struct RegistrationHelper; // IWYU pragma: keep
61 
62 
67  class DerivedNodeFactory: private boost::noncopyable
68  {
69  friend class NodeTreeBuilder;
70 
71  public:
72 
74  template< typename T > friend struct RegistrationHelper;
75 
76  private:
82 
86  virtual ~DerivedNodeFactory ();
87 
88 
89  public:
94  static DerivedNodeFactory& getInstance();
95 
96 
97  private:
98 
99  Node* convertToClassType( Node* aNode );
100 
101  /*
102  Method to create an associate between a node type identifier and a Creator of that particular node type
103  @param aNodeClassName the node type identifier
104  */
105  template <class T>
106  void add ( const std::string& aNodeClassName );
107 
108 
111  {
112  public:
117  {
118  }
123  {
124  }
130  virtual Node* create ( const Node& aNode ) = 0;
131  };
132 
133 
135  template <class T>
136  class Creator: public CreatorInterface
137  {
138  public:
139 
144  {
145  }
149  virtual ~Creator()
150  {
151  }
157  Node* create ( const Node& aNode );
158  };
159 
160 
161  private:
164 
166  boost::unordered_map< std::string , boost::shared_ptr< CreatorInterface > > mCreators;
167 
168  };
169 }
170 
172 
173 #endif
A class to build a node tree from an Address table file NOTE! This is a factory method and must be Mu...
boost::unordered_map< std::string, boost::shared_ptr< CreatorInterface > > mCreators
Hash map associating a creator for a particular node type with a string identifier for that node type...
static DerivedNodeFactory * mInstance
The single instance of the class.
A heirarchical node for navigating heirarchical firmwares.
Definition: Node.hpp:83
A singleton class to register derived nodes, and create instances of them later NOTE! This is a facto...
An abstract base class for defining the interface to the creators.
Templated concrete implementation with a CreatorInterface interface.
Experimental!! Helper struct for adding the DerivedNode to the Node Factory Declaring an instance of ...
Definition: DerivedNode.hpp:81