source: pacpusframework/trunk/include/Pacpus/kernel/ComponentBase.h@ 69

Last change on this file since 69 was 66, checked in by Marek Kurdej, 12 years ago

Documentation: file info.

  • Property svn:keywords set to Id
File size: 3.9 KB
RevLine 
[62]1// This file is part of the PACPUS framework distributed under the
2// CECILL-C License, Version 1.0.
3//
[66]4/// @file
[62]5/// @author Gerald Dhermobez <firstname.surname@utc.fr>
6/// @author Marek Kurdej <firstname.surname@utc.fr>
7/// @author Samuel Gosselin <firstname.surname@utc.fr>
[63]8/// @date February, 2006
[62]9/// @version $Id: ComponentBase.h 66 2013-01-09 16:54:11Z kurdejma $
10/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
[63]11/// @brief Generic ComponentBase class. This is an abstract class.
[62]12///
13/// Detailed description.
[63]14/// @todo - see if some methods can be private with ComponentManager
15/// friendship
16/// - include the copy of Xml node in param here
17/// - see if there is a possibility to avoid the constraint
18/// on parameters in the constructor of derived class
[62]19
[30]20#ifndef DEF_PACPUS_COMPONENTBASE_H
21#define DEF_PACPUS_COMPONENTBASE_H
[3]22
[30]23#include <Pacpus/kernel/ComponentManager.h>
24#include <Pacpus/kernel/pacpus.h>
25#include <Pacpus/kernel/XmlComponentConfig.h>
[3]26
27#include <QString>
28
[42]29namespace pacpus {
30
31// Forward declarations.
32class ComponentManager;
33
34/** ComponentBase
35 * @brief Base class of a Pacpus component.
36 */
37class PACPUSLIB_API ComponentBase
[30]38{
[3]39 friend class ComponentManager;
[42]40public:
41 /**
42 * Enumeration of the state that can take a component, the three last states suppose
43 * that the component is started.
44 */
45 enum COMPONENT_STATE
46 {
47 STOPPED,
48 NOT_MONITORED,
49 MONITOR_OK,
50 MONITOR_NOK
51 };
[3]52
[42]53 /** Resulting state of a component after its configuration. */
54 enum COMPONENT_CONFIGURATION
55 {
56 CONFIGURED_OK,
57 NOT_CONFIGURED,
58 CONFIGURATION_DELAYED,
59 CONFIGURED_FAILED
60 };
[3]61
[42]62 /** Ctor of ComponentBase.
63 * @param name Name of your component.
64 */
65 ComponentBase(const QString& name);
[3]66
[42]67 /** Dtor of ComponentBase. */
68 virtual ~ComponentBase();
[3]69
[42]70 /** Return the state of the component.
71 * @return Value of the current state.
72 */
73 COMPONENT_STATE getState();
[3]74
[42]75 /** Check whether the component if configurer or not.
76 * @return True if the component is configured, otherwise false.
77 */
78 bool isConfigured() const;
[3]79
[42]80protected:
81 /** Change the state of the component.
82 * @param state New component state.
83 */
84 void setState(COMPONENT_STATE state);
[3]85
[42]86 /** Called when the component starts, you must override this function. */
87 virtual void startActivity() = 0;
[3]88
[42]89 /** Called when the component stops, you must override this function. */
90 virtual void stopActivity() = 0;
[3]91
[42]92 /** Called by the ComponentManager, it configure the component thanks a XML node.
93 * @param config Component's XML node.
94 * @return State of the configuration.
95 * FIXME: 'config' should be const, but we can't change the prototype without breaking
96 * old stuff.
97 */
98 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config) = 0;
[61]99
100protected:
101 /// The XML node that is got in the configureComponent method
[42]102 XmlComponentConfig param;
[3]103
[61]104 /// the name of the component. It is this one in the XML config file
[42]105 QString componentName;
[3]106
[61]107 /// is the component is recording data?
[42]108 bool recording;
[3]109
[61]110 /// provided for compatibility with old DBITE framework
[42]111 bool THREAD_ALIVE;
[3]112
[61]113 /// is the component active?
[42]114 bool mIsActive;
[3]115
[61]116 /// a pointer to the manager of components
[42]117 ComponentManager * mgr;
[3]118
[42]119private:
[61]120 /// called by the ComponentManager to start the component
[42]121 int startComponent();
[3]122
[61]123 /// called by the ComponentManager to stop the component
[42]124 int stopComponent();
[3]125
[61]126 /// store the state of the component
[42]127 COMPONENT_STATE componentState_;
[3]128
[61]129 /// is the component configured (ie configureComponent method was called)
[42]130 COMPONENT_CONFIGURATION configuration_;
131};
[3]132
[42]133} // pacpus
134
135#endif // DEF_PACPUS_COMPONENTBASE_H
Note: See TracBrowser for help on using the repository browser.