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

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

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 2.4 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/// @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)
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
29ComponentBase::~ComponentBase()
30{
31 LOG_TRACE("destructor");
32}
33
34int ComponentBase::startComponent()
35{
36 if (mIsActive)
37 return false;
38
39 mIsActive = true;
40 startActivity();
41
42 return true;
43}
44
45int ComponentBase::stopComponent()
46{
47 if (!mIsActive)
48 return false;
49
50 mIsActive = false;
51 stopActivity();
52
53 return true;
54}
55
56void ComponentBase::setState(const COMPONENT_STATE state)
57{
58 componentState_ = state;
59}
60
61// FIXME: this should be const.
62ComponentBase::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
71bool ComponentBase::isConfigured() const
72{
73 return configuration_ == CONFIGURED_OK;
74}
75
76QString ComponentBase::getName() const
77{
78 return componentName;
79}
80
81InputInterfaceBase * ComponentBase::getInput(QString inputName) const
82{
83
84 if(input.contains(inputName))
85 return input[inputName];
86 else {
87 LOG_WARN("Component " << componentName << " does not containt input " << inputName);
88 return NULL;
89 }
90}
91
92OutputInterfaceBase * ComponentBase::getOutput(QString outputName) const
93{
94/* QList<QString> keys = output.keys();
95 for(int i=0; i<keys.size();++i)
96 LOG_INFO("Key : " << keys[i])*/;
97
98 if(output.contains(outputName))
99 return output[outputName];
100 else {
101 LOG_WARN("Component " << componentName << " does not containt output " << outputName);
102 return NULL;
103 }
104}
Note: See TracBrowser for help on using the repository browser.