Remove warnings
[anna.git] / include / anna / core / util / ComponentManager.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_core_util_ComponentManager_hpp
10 #define anna_core_util_ComponentManager_hpp
11
12 #include <anna/core/Singleton.hpp>
13 #include <anna/core/RuntimeException.hpp>
14
15 // STL
16 #include <string>
17 #include <map>
18
19 namespace anna {
20 namespace xml {
21 class Node;
22 }
23 }
24
25 namespace anna {
26
27 class Component;
28
29 class ComponentManager : public Singleton <ComponentManager> {
30
31 public:
32
33   /**
34      Returns component instance for the class name provided, <null> if not found.
35      \return component instance for the class name provided, <null> if not found.
36   */
37   Component* find(const char* className) throw();
38
39   /**
40      Class XML representation.
41      \param parent XML node over which we will put instance information.
42      \return XML documentcon with class content.
43   */
44   virtual xml::Node* asXML(xml::Node* parent) const throw();
45
46
47 private:
48
49   std::map < std::string /* class name */, Component* > a_components;
50
51
52   // private constructor
53   ComponentManager() {};
54
55   // private destructor
56   virtual ~ComponentManager() {};
57
58   void attach(Component*) throw(RuntimeException);
59   void detach(Component*) throw(RuntimeException);
60
61
62   friend class Singleton <ComponentManager>;
63   friend class Component;  // to access attach & detach
64 };
65
66 }
67
68 #endif
69