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

Last change on this file since 52 was 42, checked in by sgosseli, 12 years ago
  • Coding style
  • License header
  • Some clean-up
File size: 1.6 KB
Line 
1/**
2 *
3 * This file is part of the PACPUS framework distributed under the
4 * CECILL-C License, Version 1.0.
5 *
6 * @author Samuel Gosselin
7 * @date December, 2012
8 * @version $Id$
9 * @copyright Copyright (c) UTC/CNRS Heudiasyc 2005 - 2013. All rights reserved.
10 *
11 */
12
13#include <Pacpus/kernel/ComponentBase.h>
14#include <Pacpus/kernel/ComponentManager.h>
15#include <Pacpus/kernel/Log.h>
16
17using namespace pacpus;
18
19DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
20
21ComponentBase::ComponentBase(const QString& name)
22 : componentName(name)
23 , recording(true)
24 , THREAD_ALIVE(true)
25 , mIsActive(false)
26 , mgr(NULL)
27 , componentState_(NOT_MONITORED)
28{
29 LOG_TRACE("constructor");
30 // Get a pointer on the instance of ComponentManager.
31 mgr = ComponentManager::getInstance();
32 LOG_INFO("component " << componentName << " was created");
33}
34
35ComponentBase::~ComponentBase()
36{
37 LOG_TRACE("destructor");
38}
39
40int ComponentBase::startComponent()
41{
42 if (mIsActive)
43 return false;
44
45 mIsActive = true;
46 startActivity();
47
48 return true;
49}
50
51int ComponentBase::stopComponent()
52{
53 if (!mIsActive)
54 return false;
55
56 mIsActive = false;
57 stopActivity();
58
59 return true;
60}
61
62void ComponentBase::setState(const COMPONENT_STATE state)
63{
64 componentState_ = state;
65}
66
67// FIXME: this should be const.
68ComponentBase::COMPONENT_STATE ComponentBase::getState()
69{
70 COMPONENT_STATE state = componentState_;
71 if (ComponentBase::NOT_MONITORED != componentState_) {
72 componentState_ = ComponentBase::MONITOR_NOK;
73 }
74 return state;
75}
76
77bool ComponentBase::isConfigured() const
78{
79 return configuration_ == CONFIGURED_OK;
80}
Note: See TracBrowser for help on using the repository browser.