From: Eduardo Ramos Testillano Date: Sat, 6 Jun 2015 15:37:34 +0000 (+0200) Subject: app component inherits from core component. OamModule uses name instead of class... X-Git-Tag: REFACTORING_TESTING_LIBRARY~133 X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=f1060689be5a576ea46b9f95a91d19cc10444fba app component inherits from core component. OamModule uses name instead of class name to avoid confusion --- diff --git a/include/anna/app/Component.hpp b/include/anna/app/Component.hpp index efd57b1..33198d8 100644 --- a/include/anna/app/Component.hpp +++ b/include/anna/app/Component.hpp @@ -10,10 +10,7 @@ #define anna_app_Component_hpp #include - -#include -#include - +#include #include namespace anna { @@ -44,19 +41,13 @@ namespace app { Si el componente \em 'Clase' no hubiera sido registrado (instanciado) en nuestra aplicacion el metodo template anna::component lanzara una excepcion. */ -class Component : public Mutex { +class Component : public anna::Component { public: /** Destructor. */ virtual ~Component(); - /** - Class name given in constructor. - \return El nombre de la clase indicado en el constructor. - */ - const char* getClassName() const throw() { return a_className.c_str(); } - /** Conecta explicitamente este componente con la aplicacion. Sera necesario invocar a este metodo cuando instanciemos un componentes despues de comenzar la ejecucion de nuestra aplicacion y @@ -129,7 +120,6 @@ protected: private: typedef std::vector ::iterator iterator; - const std::string a_className; State::_v a_state; std::vector a_predecessors; diff --git a/include/anna/core/oam/Module.hpp b/include/anna/core/oam/Module.hpp index 39bc31c..d3c3542 100644 --- a/include/anna/core/oam/Module.hpp +++ b/include/anna/core/oam/Module.hpp @@ -137,7 +137,7 @@ class Module { Handler a_defaultHandler; // default OAM handler Handler *a_handler; // Handler reference - std::string a_className; // module description + std::string a_name; // module description bool a_counters_enabled; // Enable/Disable registered counters over this module (default is 'false') bool a_alarms_enabled; // Enable/Disable registered alarms over this module (default is 'false') @@ -208,9 +208,9 @@ public: /** Constructor - @param className Logical name for the class (better use fullNaming format including namespace resolution) + @param name Logical name for the class (better use fullNaming format including namespace resolution) */ - Module(const std::string &className) : a_className(className), + Module(const std::string &name) : a_name(name), a_handler(&a_defaultHandler), a_counters_enabled(false), a_counterRecorder(NULL), @@ -385,7 +385,7 @@ public: @param OAM module name */ - const char *getClassName() const throw() { return a_className.c_str(); } + const char *getName() const throw() { return a_name.c_str(); } /** diff --git a/include/anna/core/util/Component.hpp b/include/anna/core/util/Component.hpp index be4273c..6188f1c 100644 --- a/include/anna/core/util/Component.hpp +++ b/include/anna/core/util/Component.hpp @@ -26,13 +26,7 @@ namespace anna { Component parent class It must be only one instance for each component, but we can't inherit them from anna::Singleton because the - programmer must have the posibility to re-implement the component. The main difference regarding anna components - is that anna component are not associated to the application, allowing to be used on non-anna applications - (instead of anna application, component is got internally through a singleton anna::ComponentManager). - In this way, some anna libraries could build resources based on this, allowing its use by many kind of projects. - - ANNA components excludes concept of predecessor component and start/stop procedures, because complete use of - components must be done over pure-anna applications with its anna::app::componet resources. + programmer must have the posibility to re-implement the component. \code Class* object = anna::functions::component (FILE_LOCATION); @@ -72,17 +66,15 @@ public: protected: + const std::string a_className; + /** Contructor. @param className Logical name for tha class. */ explicit Component(const char* className); -private: - - const std::string a_className; - - //Component (const Component& other); + Component (const Component& other); }; } diff --git a/source/app/Application.cpp b/source/app/Application.cpp index bf5d6b7..003f7ed 100644 --- a/source/app/Application.cpp +++ b/source/app/Application.cpp @@ -274,8 +274,9 @@ throw(RuntimeException) { if(ii != end()) { LOGINFORMATION( - string msg((*ii)->asString()); - msg += " | Was previously attached"; + //string msg((*ii)->asString()); + string msg((*ii)->getClassName()); + msg += " | Was previously attached !"; Logger::write(Logger::Information, msg, ANNA_FILE_LOCATION); ) return; diff --git a/source/app/Component.cpp b/source/app/Component.cpp index a77c084..ca3e515 100644 --- a/source/app/Component.cpp +++ b/source/app/Component.cpp @@ -20,7 +20,7 @@ using namespace std; using namespace anna; app::Component::Component(const char* className) : - a_className(className), + anna::Component(className), a_state(State::Stopped) { Application& app(app::functions::getApp()); @@ -111,18 +111,11 @@ throw(RuntimeException) { std::string app::Component::asString() const throw() { - std::string result("app::Component { Name: "); - result += a_className; - result += " | Reference: "; - result += functions::asHexString(anna_ptrnumber_cast(this)); - return result += " }"; + return anna::Component::asString(); } xml::Node* app::Component::asXML(xml::Node* parent) const throw() { - xml::Node* result = parent->createChild("app.Component"); - result->createAttribute("Name", a_className); - result->createAttribute("Reference", functions::asHexString(anna_ptrnumber_cast(this))); - return result; + return anna::Component::asXML(parent); } diff --git a/source/core/oam/Module.cpp b/source/core/oam/Module.cpp index ede3001..4466ca5 100644 --- a/source/core/oam/Module.cpp +++ b/source/core/oam/Module.cpp @@ -256,7 +256,7 @@ void anna::oam::Module::initializeCounterScope(const int & scopeId, const std::s anna::Logger::warning("This is not the first initialized scope. Perhaps you should provide specific description better than general module name ...", ANNA_FILE_LOCATION); } ); - const char * c_description = (missingScopeDescription ? getClassName() : description.c_str()); + const char * c_description = (missingScopeDescription ? getName() : description.c_str()); a_active_counter_scope = new CounterScope(scopeId, c_description); a_scopes[scopeId] = a_active_counter_scope; } @@ -398,7 +398,7 @@ void anna::oam::Module::activateAlarm(int type, ...) const throw(anna::RuntimeEx LOGDEBUG ( std::string msg = "Alarm activation ignored over module '"; - msg += getClassName(); + msg += getName(); msg += "': alarms are disabled"; anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); @@ -424,7 +424,7 @@ void anna::oam::Module::cancelAlarm(int type, ...) const throw(anna::RuntimeExce LOGDEBUG ( std::string msg = "Alarm cancellation ignored over module '"; - msg += getClassName(); + msg += getName(); msg += "': alarms are disabled"; anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); @@ -450,7 +450,7 @@ void anna::oam::Module::count(const int & type, const int & amount) throw(anna:: LOGDEBUG ( std::string msg = "Count operation ignored over module '"; - msg += getClassName(); + msg += getName(); msg += "': counters are disabled"; anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); @@ -546,7 +546,7 @@ void anna::oam::Module::recordCounters() throw(anna::RuntimeException) { std::string anna::oam::Module::asString(void) const throw() { std::string trace; trace = "Module name: '"; - trace += getClassName(); + trace += getName(); trace += "'"; trace += "\n\nCOUNTERS"; trace += "\n--------"; trace += "\nScoped counters "; trace += a_counters_enabled ? "Enabled" : "Disabled"; @@ -607,7 +607,7 @@ std::string anna::oam::Module::asString(void) const throw() { //------------------------------------------------------------------------------ anna::xml::Node* anna::oam::Module::asXML(anna::xml::Node* parent) const throw() { anna::xml::Node* result = parent->createChild("oam.Module"); - result->createAttribute("Name", getClassName()); + result->createAttribute("Name", getName()); result->createAttribute("Counters", a_counters_enabled ? "Enabled" : "Disabled"); anna::xml::Node* registeredCounterScopes = result->createChild("RegisteredCounterScopes"); diff --git a/source/core/util/ComponentManager.cpp b/source/core/util/ComponentManager.cpp index 97bb7a1..9f486a6 100644 --- a/source/core/util/ComponentManager.cpp +++ b/source/core/util/ComponentManager.cpp @@ -39,7 +39,8 @@ throw(anna::RuntimeException) { if(already) { LOGINFORMATION( - std::string msg(already->asString()); + //std::string msg(already->asString()); + std::string msg(already->getClassName()); msg += " | Was previously attached !"; anna::Logger::information(msg, ANNA_FILE_LOCATION); )