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

Last change on this file since 40 was 31, checked in by sgosseli, 12 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

File size: 1.8 KB
Line 
1/**
2 *
3 * Distributed under the UTC Heudiascy Pacpus License, Version 1.0.
4 * Copyright (c) UTC Heudiasyc 2010 - 2013. All rights reserved.
5 *
6 * See the LICENSE file for more information or a copy at:
7 * http://www.hds.utc.fr/~kurdejma/LICENSE_1_0.txt
8 *
9 */
10
11#include <Pacpus/kernel/ComponentBase.h>
12#include <Pacpus/kernel/ComponentManager.h>
13#include <Pacpus/kernel/Log.h>
14
15using namespace pacpus;
16
17DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
18
19ComponentBase::ComponentBase(const 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
43int ComponentBase::startComponent()
44{
45 if (mIsActive == 0) {
46 mIsActive = 1;
47 startActivity();
48 return 1;
49 } else {
50 return 0;
51 }
52}
53
54int ComponentBase::stopComponent()
55{
56 if (mIsActive == 1) {
57 mIsActive = 0;
58 stopActivity();
59 return 1;
60 } else {
61 return 0;
62 }
63}
64
65void ComponentBase::setState(const COMPONENT_STATE state)
66{
67 if (state != componentState_) {
68 componentState_ = state;
69 }
70}
71
72// FIXME: this should be const.
73ComponentBase::COMPONENT_STATE ComponentBase::getState()
74{
75 COMPONENT_STATE state = componentState_;
76 if (ComponentBase::NOT_MONITORED != componentState_) {
77 componentState_ = ComponentBase::MONITOR_NOK;
78 }
79 return state;
80}
81
82bool ComponentBase::isConfigured() const
83{
84 return CONFIGURED_OK == configuration_;
85}
Note: See TracBrowser for help on using the repository browser.