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

Last change on this file since 76 was 76, checked in by Marek Kurdej, 11 years ago

Added: automated license updating lines:
%pacpus:license{
%pacpus:license}

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