Changed LICENSE. Now referenced to web site and file on project root directory
[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. The main difference regarding anna components
30    is that anna component are not associated to the application, allowing to be used on non-anna applications
31    (instead of anna application, component is got internally through a singleton anna::ComponentManager).
32    In this way, some anna libraries could build resources based on this, allowing its use by many kind of projects.
33
34    ANNA components excludes concept of predecessor component and start/stop procedures, because complete use of
35    components must be done over pure-anna applications with its anna::app::componet resources.
36
37    \code
38       Class* object = anna::functions::component <Class> (FILE_LOCATION);
39
40       ..... object use ....
41    \endcode
42
43    If component 'Class' hasn't been registered, #anna::functions::component will launch an exception.
44 */
45 class Component : public anna::Mutex {
46 public:
47   /**
48      Destructor.
49   */
50   virtual ~Component();
51
52   /**
53      Gets the class name configured at constructor.
54      \return The class name configured at constructor.
55   */
56   const char* getClassName() const throw() { return a_className.c_str(); }
57
58   /**
59   * Class string representation
60   *
61   * @return String with class content
62   */
63   virtual std::string asString(void) const throw();
64
65   /**
66      Class XML representation.
67      \param parent XML node over which we will put instance information.
68      \return XML documentcon with class content.
69   */
70   virtual anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
71
72
73 protected:
74
75   /**
76      Contructor.
77      @param className Logical name for tha class.
78   */
79   explicit Component(const char* className);
80
81 private:
82
83   const std::string a_className;
84
85   //Component (const Component& other);
86 };
87
88 }
89
90 #endif
91