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