1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
9 #ifndef anna_app_functions_hpp
10 #define anna_app_functions_hpp
12 #include <anna/core/functions.hpp>
14 #include <anna/app/Application.hpp>
23 functions - Metodos y variables
25 struct functions : public anna::functions {
27 Devuelve la referencia de la instancia de nuestra aplicacion
29 static Application& getApp() noexcept(false);
33 Pattern to obtain a multi named application component instance easily.
34 Parameters are usually replaced by the macro C <b>FILE_LOCATION</b>.
36 \param className Application component class name
37 \param fromFile File which called the method
38 \param fromLine Line number within the file from where the method is called.
40 \return Application component instance for the class provided at the pattern
43 template <typename T> static T* componentByName(const char *className, const char* fromFile, const int fromLine)
45 T* result = static_cast <T*>(functions::getApp().find(className));
48 std::string msg(className);
49 msg += " | Componente no registrado";
50 throw RuntimeException(msg, fromFile, fromLine);
58 Pattern to obtain a single named application component instance easily.
59 Parameters are usually replaced by the macro C <b>FILE_LOCATION</b>.
61 \param fromFile File which called the method
62 \param fromLine Line number within the file from where the method is called.
64 \return Application component instance for the class provided at the pattern
65 \warning T class must implement a method in the form:
67 static const char* getClassName () ;
71 template <typename T> static T* component(const char* fromFile, const int fromLine)
73 return functions::componentByName<T> (T::getClassName(), fromFile, fromLine);