Changeset 116 in pacpusframework for trunk/include/Pacpus/kernel
- Timestamp:
- Jun 25, 2013, 1:44:25 PM (11 years ago)
- Location:
- trunk/include/Pacpus/kernel
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/ComponentBase.h
r76 r116 23 23 24 24 #include <Pacpus/kernel/ComponentManager.h> 25 #include <Pacpus/kernel/ pacpus.h>25 #include <Pacpus/kernel/PacpusLibConfig.h> 26 26 #include <Pacpus/kernel/XmlComponentConfig.h> 27 27 … … 33 33 class ComponentManager; 34 34 35 /** ComponentBase 36 * @brief Base class of a Pacpus component. 37 */ 35 /// Base class of a Pacpus component. 38 36 class PACPUSLIB_API ComponentBase 39 37 { 40 38 friend class ComponentManager; 39 41 40 public: 42 /** 43 * Enumeration of the state that can take a component, the three last states suppose 44 * that the component is started. 45 */ 41 /// Enumeration of the state that can take a component, the three last states suppose 42 /// that the component is started. 46 43 enum COMPONENT_STATE 47 44 { 48 STOPPED,49 NOT_MONITORED,50 MONITOR_OK,51 MONITOR_NOK45 STOPPED, 46 NOT_MONITORED, 47 MONITOR_OK, 48 MONITOR_NOK 52 49 }; 53 50 54 / ** Resulting state of a component after its configuration. */51 /// Resulting state of a component after its configuration. 55 52 enum COMPONENT_CONFIGURATION 56 53 { 57 CONFIGURED_OK,58 NOT_CONFIGURED,59 CONFIGURATION_DELAYED,60 CONFIGURED_FAILED54 CONFIGURED_OK, 55 NOT_CONFIGURED, 56 CONFIGURATION_DELAYED, 57 CONFIGURED_FAILED 61 58 }; 62 59 63 /** Ctor of ComponentBase. 64 * @param name Name of your component. 65 */ 66 ComponentBase(const QString& name); 60 /// Ctor of ComponentBase. 61 /// @param name Name of your component. 62 ComponentBase(const QString & name); 67 63 68 / ** Dtor of ComponentBase. */64 /// Dtor of ComponentBase. 69 65 virtual ~ComponentBase(); 70 66 71 /** Return the state of the component. 72 * @return Value of the current state. 73 */ 67 /// @returns Value of the current state. 74 68 COMPONENT_STATE getState(); 75 69 76 /** Check whether the component if configurer or not. 77 * @return True if the component is configured, otherwise false. 78 */ 70 /// Checks whether the component if configurer or not. 71 /// @returns @b true if the component is configured, @b false otherwise. 79 72 bool isConfigured() const; 80 73 81 74 protected: 82 /** Change the state of the component. 83 * @param state New component state. 84 */ 75 /// Change the state of the component. 76 /// @param state New component state. 85 77 void setState(COMPONENT_STATE state); 86 78 87 / ** Called when the component starts, you must override this function. */79 /// Called when the component starts, you must override this function. 88 80 virtual void startActivity() = 0; 89 81 90 / ** Called when the component stops, you must override this function. */82 /// Called when the component stops, you must override this function. 91 83 virtual void stopActivity() = 0; 92 84 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 */ 85 /// Called by the ComponentManager, it configure the component thanks a XML node. 86 /// @param config Component's XML node. 87 /// @returns State of the configuration. 88 /// @todo FIXME: 'config' should be const, but we can't change the prototype without breaking old stuff. 99 89 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config) = 0; 100 90 101 91 protected: 102 92 /// The XML node that is got in the configureComponent method … … 132 122 }; 133 123 134 } // pacpus124 } // namespace pacpus 135 125 136 126 #endif // DEF_PACPUS_COMPONENTBASE_H -
trunk/include/Pacpus/kernel/ComponentFactory.h
r115 r116 23 23 #include <Pacpus/kernel/ComponentFactoryBase.h> 24 24 25 #include <QtGlobal>26 25 #include <QString> 27 26 … … 37 36 /// @see pacpus::ComponentFactory 38 37 #define REGISTER_COMPONENT(className, factoryName) \ 39 static pacpus::ComponentFactory<className> sFactory(factoryName)38 static pacpus::ComponentFactory<className> sFactory(factoryName) 40 39 41 40 namespace pacpus { … … 50 49 { 51 50 BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ComponentBase, T>::value), "T must inherit from ComponentBase"); 51 52 52 public: 53 /** Ctor of ComponentFactory, initialize the factory of the components of type @em T. 54 * @param type Name of the type of the components. 55 */ 53 /// Ctor of ComponentFactory, initialize the factory of the components of type @em T. 54 /// @param type Name of the type of the components. 56 55 ComponentFactory(const QString& type); 57 58 / ** Dtor of ComponentFactory. */56 57 /// Dtor of ComponentFactory. 59 58 virtual ~ComponentFactory(); 60 59 61 /** Get the name of the type of the components. 62 * @return Name of the type of the components. 63 */ 60 /// Gets the name of the type of the components. 61 /// @returns Name of the type of the components. 64 62 const QString& getType() const; 65 63 66 64 protected: 67 65 virtual ComponentBase* instantiateComponent(const QString& name); 68 66 69 67 private: 70 68 QString mType; … … 73 71 template <typename T> 74 72 ComponentFactory<T>::ComponentFactory(const QString& type) 75 : mType(type)73 : mType(type) 76 74 { 77 75 assert(!type.isEmpty()); … … 96 94 } 97 95 98 } // pacpus96 } // namespace pacpus 99 97 100 98 #endif // DEF_PACPUS_DBITEEXCEPTION_H -
trunk/include/Pacpus/kernel/ComponentFactoryBase.h
r76 r116 16 16 #define DEF_PACPUS_COMPONENTFACTORYBASE_H 17 17 18 #include <Pacpus/kernel/ pacpus.h>18 #include <Pacpus/kernel/PacpusLibConfig.h> 19 19 20 20 class QString; … … 25 25 class ComponentBase; 26 26 27 /** ComponentFactoryBase 28 * @brief Provide an abstract class to the template ComponentFactory. 29 */ 27 /// ComponentFactoryBase 28 /// @brief Provide an abstract class to the template ComponentFactory. 30 29 class PACPUSLIB_API ComponentFactoryBase 31 30 { 32 31 friend class ComponentManager; 32 33 33 public: 34 / ** Ctor of ComponentFactoryBase. */34 /// Ctor of ComponentFactoryBase. 35 35 ComponentFactoryBase(); 36 / ** Dtor of ComponentFactoryBase. */36 /// Dtor of ComponentFactoryBase. 37 37 virtual ~ComponentFactoryBase(); 38 38 39 39 protected: 40 /** Create a new component having @em name as component name. 41 * @param name Name of the instantiated component. 42 * @return Pointer on the newly created component, you become the owner of its lifetime. 43 */ 40 /// Creates a new component having @em name as component name. 41 /// Caller becomes the owner of its lifetime 42 /// 43 /// @param name Name of the instantiated component. 44 /// @returns Pointer on the newly created component. 44 45 virtual ComponentBase * instantiateComponent(const QString& name) = 0; 45 46 46 / ** Registera new factory.47 * @param addr Address of the factory.48 * @param type Name of the type created bythe factory.49 */47 /// Registers a new factory. 48 /// 49 /// @param addr Address of the factory. 50 /// @param type Name of the type created by the factory. 50 51 void addFactory(ComponentFactoryBase* addr, const QString& type); 51 52 52 / ** Adda new component.53 * @param name Name of the new component.54 */53 /// Adds a new component. 54 /// 55 /// @param name Name of the new component. 55 56 void addComponent(const QString& name); 56 57 -
trunk/include/Pacpus/kernel/ComponentManager.h
r76 r116 18 18 #define DEF_PACPUS_COMPONENTMANAGER_H 19 19 20 #include <Pacpus/kernel/ComponentFactoryBase.h> 20 21 #include <Pacpus/kernel/pacpus.h> 21 #include <Pacpus/kernel/ ComponentFactoryBase.h>22 #include <Pacpus/kernel/PacpusLibConfig.h> 22 23 #include <Pacpus/kernel/PacpusPluginInterface.h> 23 24 #include <Pacpus/kernel/XmlConfigFile.h> … … 41 42 { 42 43 friend class ComponentBase; 44 45 // Allow 2 functions to access to private members of ComponentManager 46 friend void ComponentFactoryBase::addFactory(ComponentFactoryBase * addr, const QString & type); 47 friend void ComponentFactoryBase::addComponent(const QString & name); 43 48 44 49 public: … … 68 73 }; 69 74 70 /** Load the components included in the XML config file. 71 * @param file Name of the XML file. 72 * @return Number of components loaded by the manager. 73 */ 75 /// Loads the components included in the XML config file. 76 /// @param file Name of the XML file. 77 /// @returns Number of components loaded by the manager. 74 78 PACPUSLIB_API std::size_t loadComponents(const QString& file); 75 79 76 /** Start all the components 77 * @return True if all the component has been started, otherwise false. 78 */ 80 /// Starts all the components 81 /// @return @b true if all the component has been started, @b false otherwise. 79 82 PACPUSLIB_API bool start(); 80 83 81 /** Start only the component passed in parameter. 82 * @param component Component to start. 83 * @return True if the component exists and has been started, otherwise false. 84 */ 84 /// Starts only the component passed in parameter. 85 /// @param component Component to start. 86 /// @returns @b true if the component exists and has been started, @b false otherwise. 85 87 PACPUSLIB_API bool start(const QString& component); 86 88 87 /** Stop all the components 88 * @return True if all the component has been stopped, otherwise false. 89 */ 89 /// Stops all the components 90 /// @returns @b true if all the component has been stopped, @b false otherwise. 90 91 PACPUSLIB_API bool stop(); 91 92 92 /** Stop only the component passed in parameter. 93 * @param component Component to stop. 94 * @return True if the component has been stopped, otherwise false. 95 */ 93 /// Stops only the component passed in parameter. 94 /// @param component Component to stop. 95 /// @returns @b true if the component has been stopped, @b false otherwise. 96 96 PACPUSLIB_API bool stop(const QString& component); 97 97 98 / ** Geta pointer to the component referred by @em name.99 * @param name Name of the component.100 * @return Pointer to the component if it exists, otherwise @em NULL.101 */98 /// Gets a pointer to the component referred by @em name. 99 /// 100 /// @param name Name of the component. 101 /// @returns Pointer to the component if it exists, @b NULL otherwise. 102 102 PACPUSLIB_API ComponentBase* getComponent(const QString& name); 103 103 104 /** Get the list of all the names of the component known by the manager. 105 * @return List of all the component's name. 106 */ 104 /// Gets the list of all the names of the component known by the manager. 105 /// @returns List of all the component's name. 107 106 PACPUSLIB_API QStringList getAllComponentsName() const; 108 107 109 /** Load a new plugin from the file filename (it may be a .so/.dll file) 110 * @param filename Name of the shared object or the dll. 111 * @return True if the plugin has been loaded, otherwise false. 112 */ 108 /// Loads a new plugin from the file filename (it may be a .so/.dll file) 109 /// @param filename Name of the shared object or the dll. 110 /// @returns @b true if the plugin has been loaded, @b false otherwise . 113 111 PACPUSLIB_API bool loadPlugin(const QString& filename); 114 112 … … 118 116 119 117 bool registerComponent(ComponentBase* addr, const QString& name); 120 bool registerComponentFactory(ComponentFactoryBase * addr, const QString& type);118 bool registerComponentFactory(ComponentFactoryBase * addr, const QString& type); 121 119 122 120 bool unRegisterComponent(const QString& name); 123 121 bool unRegisterComponentFactory(const QString& type); 124 125 // Allow 2 functions to access to private members of ComponentManager126 friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString & type);127 friend void ComponentFactoryBase::addComponent(const QString & name);128 122 129 123 /// private constructor accessible only via static create() function -
trunk/include/Pacpus/kernel/DbiteException.h
r114 r116 16 16 17 17 #include <Pacpus/kernel/FileLibConfig.h> 18 #include <Pacpus/kernel/PacpusException.h> 18 19 19 20 #include <exception> 20 21 #include <string> 21 22 22 #ifdef _MSC_VER23 # pragma warning(push)24 # pragma warning(disable: 4251)25 #endif // _MSC_VER26 27 23 namespace pacpus { 28 24 29 /** DbiteException 30 * @brief Exception thrown when an error manipulation a dbite file occured. 31 */ 25 /// DbiteException 26 /// @brief Exception thrown when an error manipulation a dbite file occured. 32 27 class FILELIB_API DbiteException 33 : public std::exception28 : virtual public PacpusException 34 29 { 35 30 public: 36 /** Ctor of DbiteException. 37 * @param what Information about the exception. 38 */ 39 DbiteException(const std::string& what); 31 /// Ctor. 32 /// @param what Information about the exception. 33 DbiteException(const std::string & what); 40 34 41 / ** Dtor of DbiteException. */35 /// Dtor. 42 36 virtual ~DbiteException() throw(); 43 44 45 /** Get more information about the error.46 * @return Message containing information about the error.47 */48 virtual const char* what() const throw();49 50 51 private:52 std::string mWhat;53 37 }; 54 38 55 39 } // namespace pacpus 56 40 57 #ifdef _MSC_VER58 # pragma warning(pop)59 #endif // _MSC_VER60 61 41 #endif // DEF_PACPUS_DBITEEXCEPTION_H -
trunk/include/Pacpus/kernel/FileLibConfig.h
r76 r116 18 18 #define DEF_PACPUS_FILELIBCONFIG_H 19 19 20 // Export macro for FileLib DLL for Windows only20 /// Export macro for FileLib DLL for Windows only 21 21 #ifdef WIN32 22 22 # ifdef FILELIB_EXPORTS -
trunk/include/Pacpus/kernel/Log.h
r112 r116 15 15 #define DEF_PACPUS_LOG_H 16 16 17 // Includes, pacpus. 18 #include <Pacpus/kernel/pacpus.h> 17 #include <Pacpus/kernel/PacpusLibConfig.h> 19 18 20 19 namespace pacpus { … … 43 42 static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name)) 44 43 45 / * https://devel.hds.utc.fr/projects/pacpus/ticket/55 */44 // https://devel.hds.utc.fr/projects/pacpus/ticket/55 46 45 #define LOG_TRACE(message) do{LOG4CXX_TRACE(logger, message);} while(false) 47 46 #define LOG_DEBUG(message) do{LOG4CXX_DEBUG(logger, message);} while(false) -
trunk/include/Pacpus/kernel/XmlComponentConfig.h
r91 r116 15 15 #define DEF_PACPUS_XMLCOMPONENTCONFIG_H 16 16 17 #include <Pacpus/kernel/ pacpus.h>17 #include <Pacpus/kernel/PacpusLibConfig.h> 18 18 19 19 #include <QDomElement> … … 23 23 class XmlConfigFile; 24 24 25 /** XmlComponentConfig 26 * @brief Defines the XML structure of a component. 27 */ 25 /// XmlComponentConfig 26 /// @brief Defines the XML structure of a component. 28 27 class PACPUSLIB_API XmlComponentConfig 29 28 { 30 29 friend class ComponentManager; 30 31 31 public: 32 /** Ctor of XmlComponentConfig. 33 * @param name Name of the ComponentFactory, by convention equal to class name. 34 */ 35 explicit XmlComponentConfig(const QString& name = QString::null); 32 /// Ctor of XmlComponentConfig. 33 /// @param name Name of the ComponentFactory, by convention equal to class name. 34 explicit XmlComponentConfig(const QString & name = QString::null); 36 35 37 / ** Dtor of XmlComponentConfig. */36 /// Dtor of XmlComponentConfig. 38 37 ~XmlComponentConfig(); 39 38 40 /** Add the property @em name to the XML and set its value to @em 0 if it does not exist. 41 * @param name Name of the property. 42 */ 39 /// Adds the property @em name to the XML and set its value to @em 0 if it does not exist. 40 /// @param name Name of the property. 43 41 void addProperty(const QString& name); 44 42 45 / ** Delete a propertyfrom the XML.46 * @return False if the property does not exist, false otherwise.47 */43 /// Deletes property @em name from the XML. 44 /// 45 /// @returns @b true if the property existed and was removed, @b false if the property did not exist or could not be removed. 48 46 int delProperty(const QString& name); 49 47 50 /** Get the value of a property. 51 * @param name Name of the property. 52 * @param defaultValue Value returned if the property does not exist. 53 * @return Value of the property, @em defaultValue otherwise. 54 */ 48 /// Gets the value of a property. 49 /// @param name Name of the property. 50 /// @param defaultValue Value returned if the property does not exist. 51 /// @return Value of the property, @em defaultValue otherwise. 55 52 QString getProperty(const QString& name, const QString& defaultValue = QString::null) const; 56 53 57 /** Get the value of a property as a boolean. 58 * @param name Name of the property. 59 * @param defaultValue Value returned if the property does not exist. 60 * @return Value of the property, @em defaultValue otherwise. 61 */ 54 /// Gets the value of a property as a boolean. 55 /// @param name Name of the property. 56 /// @param defaultValue Value returned if the property does not exist. 57 /// @returns Value of the property, @em defaultValue otherwise. 62 58 bool getBoolProperty(const QString& name, bool defaultValue = false) const; 63 59 64 /** Get the value of a property as an integer. 65 * @param name Name of the property. 66 * @param defaultValue Value returned if the property does not exist. 67 * @return Value of the property, @em defaultValue otherwise. 68 */ 60 /// Get the value of a property as an integer. 61 /// @param name Name of the property. 62 /// @param defaultValue Value returned if the property does not exist. 63 /// @return Value of the property, @em defaultValue otherwise. 69 64 int getIntProperty(const QString& name, int defaultValue = 0) const; 70 65 71 /** Get the value of a property as a double. 72 * @param name Name of the property. 73 * @param defaultValue Value returned if the property does not exist. 74 * @return Value of the property, @em defaultValue otherwise. 75 */ 66 /// Get the value of a property as a double. 67 /// @param name Name of the property. 68 /// @param defaultValue Value returned if the property does not exist. 69 /// @return Value of the property, @em defaultValue otherwise. 76 70 double getDoubleProperty(const QString& name, double defaultValue = 0.0) const; 77 71 78 /** Set the value of a property. 79 * @param name Name of the property. 80 * @param value Value to set. 81 */ 72 /// Set the value of a property. 73 /// @param name Name of the property. 74 /// @param value Value to set. 82 75 void setProperty(const QString& name, const QString& value); 83 76 84 /** Check if a property exists. 85 * @param name Name of the property. 86 * @return True if the property exists, false otherwise. 87 */ 77 /// Check if a property exists. 78 /// @param name Name of the property. 79 /// @return True if the property exists, false otherwise. 88 80 bool hasProperty(const QString& name) const; 89 81 -
trunk/include/Pacpus/kernel/XmlConfigFile.h
r91 r116 15 15 /// - parameters : parameters of the application 16 16 /// - components : a list of components to load 17 ///18 19 17 20 18 #ifndef DEF_PACPUS_XMLCONFIGFILE_H 21 19 #define DEF_PACPUS_XMLCONFIGFILE_H 22 20 23 #include <Pacpus/kernel/ pacpus.h>21 #include <Pacpus/kernel/PacpusLibConfig.h> 24 22 #include <Pacpus/kernel/XmlComponentConfig.h> 25 23 -
trunk/include/Pacpus/kernel/pacpus.h
r76 r116 16 16 #define DEF_PACPUS_H 17 17 18 #include <Pacpus/kernel/PacpusLibConfig.h> 18 19 #include <Pacpus/kernel/road_time.h> 19 20 … … 23 24 #ifndef PACPUS_PI 24 25 # define PACPUS_PI 3.1415926 25 #endif26 27 /// Export macro for PacpusLib DLL for Windows only28 #ifdef WIN3229 # ifdef PACPUSLIB_EXPORTS30 // make DLL31 # define PACPUSLIB_API __declspec(dllexport)32 # else33 // use DLL34 # define PACPUSLIB_API __declspec(dllimport)35 # endif36 #else37 // On other platforms, simply ignore this38 # define PACPUSLIB_API39 26 #endif 40 27 -
trunk/include/Pacpus/kernel/road_time.h
r91 r116 49 49 /// at the same time. 50 50 /// Description of each field is provided inside the structure 51 struct Initialisation_Time51 struct ROAD_TIME_API Initialisation_Time 52 52 { 53 53 /// Time (extended to micro seconds precision)
Note:
See TracChangeset
for help on using the changeset viewer.