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

Last change on this file since 32 was 30, checked in by sgosseli, 12 years ago

Major: improve the documentation of ComponentBase and use the new include style.

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