ANNA Suite  2020b
Multipurpose development suite for Telco applications
functions.hpp
Go to the documentation of this file.
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_app_functions_hpp
10 #define anna_app_functions_hpp
11 
12 #include <anna/core/functions.hpp>
13 
14 #include <anna/app/Application.hpp>
15 
16 namespace anna {
17 
18 namespace app {
19 
20 class Application;
21 
25 struct functions : public anna::functions {
29  static Application& getApp() noexcept(false);
30 
31 
43  template <typename T> static T* componentByName(const char *className, const char* fromFile, const int fromLine)
44  noexcept(false) {
45  T* result = static_cast <T*>(functions::getApp().find(className));
46 
47  if(result == NULL) {
48  std::string msg(className);
49  msg += " | Componente no registrado";
50  throw RuntimeException(msg, fromFile, fromLine);
51  }
52 
53  return result;
54  }
55 };
56 
71  template <typename T> static T* component(const char* fromFile, const int fromLine)
72  noexcept(false) {
73  return functions::componentByName<T> (T::getClassName(), fromFile, fromLine);
74  }
75 
76 }
77 }
78 
79 #endif
80 
81 
static Application & getApp() noexcept(false)
Definition: Application.hpp:35
static T * componentByName(const char *className, const char *fromFile, const int fromLine) noexcept(false)
Definition: functions.hpp:43
Component * find(const char *className)
Definition: functions.hpp:65
Definition: app.hpp:12
static T * component(const char *fromFile, const int fromLine) noexcept(false)
Definition: functions.hpp:633
Definition: functions.hpp:25
Definition: RuntimeException.hpp:23