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 |
|
---|
10 | using namespace pacpus;
|
---|
11 |
|
---|
12 | DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
|
---|
13 |
|
---|
14 | ComponentBase::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 |
|
---|
28 | ComponentBase::~ComponentBase()
|
---|
29 | {
|
---|
30 | LOG_TRACE("destructor");
|
---|
31 | }
|
---|
32 |
|
---|
33 | int ComponentBase::startComponent()
|
---|
34 | {
|
---|
35 | if (mIsActive)
|
---|
36 | return false;
|
---|
37 |
|
---|
38 | mIsActive = true;
|
---|
39 | startActivity();
|
---|
40 |
|
---|
41 | return true;
|
---|
42 | }
|
---|
43 |
|
---|
44 | int ComponentBase::stopComponent()
|
---|
45 | {
|
---|
46 | if (!mIsActive)
|
---|
47 | return false;
|
---|
48 |
|
---|
49 | mIsActive = false;
|
---|
50 | stopActivity();
|
---|
51 |
|
---|
52 | return true;
|
---|
53 | }
|
---|
54 |
|
---|
55 | void ComponentBase::setState(const COMPONENT_STATE state)
|
---|
56 | {
|
---|
57 | componentState_ = state;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // FIXME: this should be const.
|
---|
61 | ComponentBase::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 |
|
---|
70 | bool ComponentBase::isConfigured() const
|
---|
71 | {
|
---|
72 | return configuration_ == CONFIGURED_OK;
|
---|
73 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.