source: pacpusframework/branches/0.0.x/src/PacpusLib/ComponentBase.cpp

Last change on this file was 91, checked in by DHERBOMEZ Gérald, 11 years ago

Improvement of the build system to avoid some workarounds

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