source: pacpusframework/branches/2.0-beta1/src/PacpusLib/ComponentBase.cpp@ 113

Last change on this file since 113 was 110, checked in by morasjul, 11 years ago

Beta-2 : Fix CMakeList (link), remove useless code and add improvement

  • Property svn:executable set to *
File size: 2.4 KB
RevLine 
[89]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/// @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
11using namespace pacpus;
12
13DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
14
15ComponentBase::ComponentBase(const QString& name)
16 : componentName(name)
17 , recording(true)
18 , THREAD_ALIVE(true)
19 , mIsActive(false)
20 , mgr(NULL)
21 , componentState_(NOT_MONITORED)
[110]22 , ui(NULL)
[89]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}
76
77QString ComponentBase::getName() const
78{
79 return componentName;
80}
81
82InputInterfaceBase * ComponentBase::getInput(QString inputName) const
83{
84
85 if(input.contains(inputName))
86 return input[inputName];
87 else {
88 LOG_WARN("Component " << componentName << " does not containt input " << inputName);
89 return NULL;
90 }
91}
92
93OutputInterfaceBase * ComponentBase::getOutput(QString outputName) const
94{
95/* QList<QString> keys = output.keys();
96 for(int i=0; i<keys.size();++i)
97 LOG_INFO("Key : " << keys[i])*/;
98
99 if(output.contains(outputName))
100 return output[outputName];
101 else {
102 LOG_WARN("Component " << componentName << " does not containt output " << outputName);
103 return NULL;
104 }
105}
Note: See TracBrowser for help on using the repository browser.