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

Last change on this file since 63 was 62, checked in by Marek Kurdej, 12 years ago

Update: license info.

File size: 1.5 KB
Line 
1// This file is part of the PACPUS framework distributed under the
2// CECILL-C License, Version 1.0.
3//
4/// @version $Id$
5
6#include <Pacpus/kernel/ComponentBase.h>
7#include <Pacpus/kernel/ComponentManager.h>
8#include <Pacpus/kernel/Log.h>
9
10using namespace pacpus;
11
12DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
13
14ComponentBase::ComponentBase(const QString& name)
15 : componentName(name)
16 , recording(true)
17 , THREAD_ALIVE(true)
18 , mIsActive(false)
19 , mgr(NULL)
20 , componentState_(NOT_MONITORED)
21{
22 LOG_TRACE("constructor");
23 // Get a pointer on the instance of ComponentManager.
24 mgr = ComponentManager::getInstance();
25 LOG_INFO("component " << componentName << " was created");
26}
27
28ComponentBase::~ComponentBase()
29{
30 LOG_TRACE("destructor");
31}
32
33int ComponentBase::startComponent()
34{
35 if (mIsActive)
36 return false;
37
38 mIsActive = true;
39 startActivity();
40
41 return true;
42}
43
44int ComponentBase::stopComponent()
45{
46 if (!mIsActive)
47 return false;
48
49 mIsActive = false;
50 stopActivity();
51
52 return true;
53}
54
55void ComponentBase::setState(const COMPONENT_STATE state)
56{
57 componentState_ = state;
58}
59
60// FIXME: this should be const.
61ComponentBase::COMPONENT_STATE ComponentBase::getState()
62{
63 COMPONENT_STATE state = componentState_;
64 if (ComponentBase::NOT_MONITORED != componentState_) {
65 componentState_ = ComponentBase::MONITOR_NOK;
66 }
67 return state;
68}
69
70bool ComponentBase::isConfigured() const
71{
72 return configuration_ == CONFIGURED_OK;
73}
Note: See TracBrowser for help on using the repository browser.