#define anna_app_Component_hpp
#include <vector>
-
-#include <anna/core/RuntimeException.hpp>
-#include <anna/core/mt/Mutex.hpp>
-
+#include <anna/core/util/Component.hpp>
#include <anna/app/Application.hpp>
namespace anna {
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
private:
typedef std::vector <std::string>::iterator iterator;
- const std::string a_className;
State::_v a_state;
std::vector <std::string> a_predecessors;
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')
/** 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),
@param OAM module name
*/
- const char *getClassName() const throw() { return a_className.c_str(); }
+ const char *getName() const throw() { return a_name.c_str(); }
/**
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 <Class> (FILE_LOCATION);
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);
};
}
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;
using namespace anna;
app::Component::Component(const char* className) :
- a_className(className),
+ anna::Component(className),
a_state(State::Stopped) {
Application& app(app::functions::getApp());
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);
}
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;
}
LOGDEBUG
(
std::string msg = "Alarm activation ignored over module '";
- msg += getClassName();
+ msg += getName();
msg += "': alarms are disabled";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
LOGDEBUG
(
std::string msg = "Alarm cancellation ignored over module '";
- msg += getClassName();
+ msg += getName();
msg += "': alarms are disabled";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
LOGDEBUG
(
std::string msg = "Count operation ignored over module '";
- msg += getClassName();
+ msg += getName();
msg += "': counters are disabled";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
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";
//------------------------------------------------------------------------------
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");
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);
)