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

Last change on this file since 3 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
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 "kernel/ComponentBase.h"
11
12#include "kernel/ComponentManager.h"
13#include "kernel/Log.h"
14
15namespace pacpus {
16
17DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
18
19ComponentBase::ComponentBase(QString name)
20{
21 LOG_TRACE("constructor");
22
23 configuration_ = NOT_CONFIGURED;
24 componentName = name;
25 recording = true;
26 THREAD_ALIVE = true;
27 mIsActive = 0;
28 componentState_ = ComponentBase::NOT_MONITORED;
29
30 // we get a pointer on the instance of ComponentManager
31 mgr = ComponentManager::getInstance();
32
33 LOG_INFO("component " << componentName
34 << " was created"
35 );
36}
37
38ComponentBase::~ComponentBase()
39{
40 LOG_TRACE("destructor");
41}
42
43//TODO
44//COMPONENT_CONFIGURATION ComponentBase::configureComponent(XmlComponentConfig config)
45//{
46//}
47
48int ComponentBase::startComponent()
49{
50 if (mIsActive == 0) {
51 mIsActive = 1;
52 startActivity();
53 return 1;
54 } else {
55 return 0;
56 }
57}
58
59int ComponentBase::stopComponent()
60{
61 if (mIsActive == 1) {
62 mIsActive = 0;
63 stopActivity();
64 return 1;
65 } else {
66 return 0;
67 }
68}
69
70void ComponentBase::setState(const COMPONENT_STATE state)
71{
72 if (state != componentState_) {
73 componentState_ = state;
74 }
75}
76
77// return the state of the component
78ComponentBase::COMPONENT_STATE ComponentBase::getState()
79{
80 COMPONENT_STATE state = componentState_;
81 if (ComponentBase::NOT_MONITORED != componentState_) {
82 componentState_ = ComponentBase::MONITOR_NOK;
83 }
84 return state;
85}
86
87} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.