Remove dynamic exceptions
[anna.git] / include / anna / core / util / Component.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_Component_hpp
10 #define anna_core_util_Component_hpp
11
12
13
14 #include <anna/core/RuntimeException.hpp>
15 #include <anna/core/mt/Mutex.hpp>
16
17 namespace anna {
18 namespace xml {
19 class Node;
20 }
21 }
22
23 namespace anna {
24
25 /**
26    Component parent class
27
28    It must be only one instance for each component, but we can't inherit them from anna::Singleton because the
29    programmer must have the posibility to re-implement the component.
30
31    \code
32       Class* object = anna::functions::component <Class> (FILE_LOCATION);
33
34       ..... object use ....
35    \endcode
36
37    If component 'Class' hasn't been registered, #anna::functions::component will launch an exception.
38 */
39 class Component : public anna::Mutex {
40 public:
41   /**
42      Destructor.
43   */
44   virtual ~Component();
45
46   /**
47      Gets the class name configured at constructor.
48      \return The class name configured at constructor.
49   */
50   const char* getClassName() const { return a_className.c_str(); }
51
52   /**
53   * Class string representation
54   *
55   * @return String with class content
56   */
57   virtual std::string asString(void) const ;
58
59   /**
60      Class XML representation.
61      \param parent XML node over which we will put instance information.
62      \return XML documentcon with class content.
63   */
64   virtual anna::xml::Node* asXML(anna::xml::Node* parent) const ;
65
66
67 protected:
68
69   const std::string a_className;
70
71   /**
72      Contructor.
73      @param className Logical name for tha class.
74   */
75   explicit Component(const char* className);
76
77   Component (const Component& other);
78 };
79
80 }
81
82 #endif
83