source: pacpusframework/trunk/src/PacpusLib/ComponentBase.cpp@ 30

Last change on this file since 30 was 30, checked in by sgosseli, 11 years ago

Major: improve the documentation of ComponentBase and use the new include style.

File size: 1.8 KB
Line 
1/*********************************************************************
2// created: 2006/02/07 - 11:58
3// filename: ComponentBase.cpp
4//
5// author: Gerald Dherbomez
6//
7// purpose: implementation of ComponentBase class
8*********************************************************************/
9
10#include <Pacpus/kernel/ComponentBase.h>
11#include <Pacpus/kernel/ComponentManager.h>
12#include <Pacpus/kernel/Log.h>
13
14using namespace pacpus;
15
16DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
17
18ComponentBase::ComponentBase(const QString& name)
19{
20 LOG_TRACE("constructor");
21
22 configuration_ = NOT_CONFIGURED;
23 componentName = name;
24 recording = true;
25 THREAD_ALIVE = true;
26 mIsActive = 0;
27 componentState_ = ComponentBase::NOT_MONITORED;
28
29 // we get a pointer on the instance of ComponentManager
30 mgr = ComponentManager::getInstance();
31
32 LOG_INFO("component " << componentName
33 << " was created"
34 );
35}
36
37ComponentBase::~ComponentBase()
38{
39 LOG_TRACE("destructor");
40}
41
42int ComponentBase::startComponent()
43{
44 if (mIsActive == 0) {
45 mIsActive = 1;
46 startActivity();
47 return 1;
48 } else {
49 return 0;
50 }
51}
52
53int ComponentBase::stopComponent()
54{
55 if (mIsActive == 1) {
56 mIsActive = 0;
57 stopActivity();
58 return 1;
59 } else {
60 return 0;
61 }
62}
63
64void ComponentBase::setState(const COMPONENT_STATE state)
65{
66 if (state != componentState_) {
67 componentState_ = state;
68 }
69}
70
71// FIXME: this should be const.
72ComponentBase::COMPONENT_STATE ComponentBase::getState()
73{
74 COMPONENT_STATE state = componentState_;
75 if (ComponentBase::NOT_MONITORED != componentState_) {
76 componentState_ = ComponentBase::MONITOR_NOK;
77 }
78 return state;
79}
80
81bool ComponentBase::isConfigured() const
82{
83 return CONFIGURED_OK == configuration_;
84}
Note: See TracBrowser for help on using the repository browser.