Changeset 116 in pacpusframework for trunk/include/Pacpus/kernel


Ignore:
Timestamp:
Jun 25, 2013, 1:44:25 PM (11 years ago)
Author:
Marek Kurdej
Message:

Added: PacpusException - base class for all exceptions. DbiteExceptions inherits from it.
Added: PacpusLibConfig.h - dllimport/dllexport clauses separated from pacpus.h.
Update: comments.

Location:
trunk/include/Pacpus/kernel
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/kernel/ComponentBase.h

    r76 r116  
    2323
    2424#include <Pacpus/kernel/ComponentManager.h>
    25 #include <Pacpus/kernel/pacpus.h>
     25#include <Pacpus/kernel/PacpusLibConfig.h>
    2626#include <Pacpus/kernel/XmlComponentConfig.h>
    2727
     
    3333class ComponentManager;
    3434
    35 /** ComponentBase
    36  * @brief Base class of a Pacpus component.
    37  */
     35/// Base class of a Pacpus component.
    3836class PACPUSLIB_API ComponentBase
    3937{
    4038    friend class ComponentManager;
     39
    4140public:
    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.
    4643    enum COMPONENT_STATE
    4744    {
    48       STOPPED,
    49       NOT_MONITORED,
    50       MONITOR_OK,
    51       MONITOR_NOK
     45        STOPPED,
     46        NOT_MONITORED,
     47        MONITOR_OK,
     48        MONITOR_NOK
    5249    };
    5350
    54     /** Resulting state of a component after its configuration. */
     51    /// Resulting state of a component after its configuration.
    5552    enum COMPONENT_CONFIGURATION
    5653    {
    57       CONFIGURED_OK,
    58       NOT_CONFIGURED,
    59       CONFIGURATION_DELAYED,
    60       CONFIGURED_FAILED
     54        CONFIGURED_OK,
     55        NOT_CONFIGURED,
     56        CONFIGURATION_DELAYED,
     57        CONFIGURED_FAILED
    6158    };
    6259
    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);
    6763
    68     /** Dtor of ComponentBase. */
     64    /// Dtor of ComponentBase.
    6965    virtual ~ComponentBase();
    7066
    71     /** Return the state of the component.
    72      * @return Value of the current state.
    73      */
     67    /// @returns Value of the current state.
    7468    COMPONENT_STATE getState();
    7569
    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.
    7972    bool isConfigured() const;
    8073
    8174protected:
    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.
    8577    void setState(COMPONENT_STATE state);
    8678
    87     /** Called when the component starts, you must override this function. */
     79    /// Called when the component starts, you must override this function.
    8880    virtual void startActivity() = 0;
    8981
    90     /** Called when the component stops, you must override this function. */
     82    /// Called when the component stops, you must override this function.
    9183    virtual void stopActivity() = 0;
    9284
    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.
    9989    virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config) = 0;
    100    
     90
    10191protected:
    10292    /// The XML node that is got in the configureComponent method
     
    132122};
    133123
    134 } // pacpus
     124} // namespace pacpus
    135125
    136126#endif // DEF_PACPUS_COMPONENTBASE_H
  • trunk/include/Pacpus/kernel/ComponentFactory.h

    r115 r116  
    2323#include <Pacpus/kernel/ComponentFactoryBase.h>
    2424
    25 #include <QtGlobal>
    2625#include <QString>
    2726
     
    3736/// @see pacpus::ComponentFactory
    3837#define REGISTER_COMPONENT(className, factoryName) \
    39   static pacpus::ComponentFactory<className> sFactory(factoryName)
     38    static pacpus::ComponentFactory<className> sFactory(factoryName)
    4039
    4140namespace pacpus {
     
    5049{
    5150    BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ComponentBase, T>::value), "T must inherit from ComponentBase");
     51
    5252public:
    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.
    5655    ComponentFactory(const QString& type);
    57    
    58     /** Dtor of ComponentFactory. */
     56
     57    /// Dtor of ComponentFactory.
    5958    virtual ~ComponentFactory();
    6059
    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.
    6462    const QString& getType() const;
    6563
    6664protected:
    6765    virtual ComponentBase* instantiateComponent(const QString& name);
    68  
     66
    6967private:
    7068    QString mType;
     
    7371template <typename T>
    7472ComponentFactory<T>::ComponentFactory(const QString& type)
    75   : mType(type)
     73    : mType(type)
    7674{
    7775    assert(!type.isEmpty());
     
    9694}
    9795
    98 } // pacpus
     96} // namespace pacpus
    9997
    10098#endif // DEF_PACPUS_DBITEEXCEPTION_H
  • trunk/include/Pacpus/kernel/ComponentFactoryBase.h

    r76 r116  
    1616#define DEF_PACPUS_COMPONENTFACTORYBASE_H
    1717
    18 #include <Pacpus/kernel/pacpus.h>
     18#include <Pacpus/kernel/PacpusLibConfig.h>
    1919
    2020class QString;
     
    2525class ComponentBase;
    2626
    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.
    3029class PACPUSLIB_API ComponentFactoryBase
    3130{
    3231    friend class ComponentManager;
     32
    3333public:
    34     /** Ctor of ComponentFactoryBase. */
     34    /// Ctor of ComponentFactoryBase.
    3535    ComponentFactoryBase();
    36     /** Dtor of ComponentFactoryBase. */
     36    /// Dtor of ComponentFactoryBase.
    3737    virtual ~ComponentFactoryBase();
    3838
    3939protected:
    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.
    4445    virtual ComponentBase * instantiateComponent(const QString& name) = 0;
    4546   
    46     /** Register a new factory.
    47      * @param addr Address of the factory.
    48      * @param type Name of the type created by the 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.
    5051    void addFactory(ComponentFactoryBase* addr, const QString& type);
    5152   
    52     /** Add a 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.
    5556    void addComponent(const QString& name);
    5657
  • trunk/include/Pacpus/kernel/ComponentManager.h

    r76 r116  
    1818#define DEF_PACPUS_COMPONENTMANAGER_H
    1919
     20#include <Pacpus/kernel/ComponentFactoryBase.h>
    2021#include <Pacpus/kernel/pacpus.h>
    21 #include <Pacpus/kernel/ComponentFactoryBase.h>
     22#include <Pacpus/kernel/PacpusLibConfig.h>
    2223#include <Pacpus/kernel/PacpusPluginInterface.h>
    2324#include <Pacpus/kernel/XmlConfigFile.h>
     
    4142{
    4243    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);
    4348
    4449public:
     
    6873    };
    6974
    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.
    7478    PACPUSLIB_API std::size_t loadComponents(const QString& file);
    7579
    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.
    7982    PACPUSLIB_API bool start();
    8083
    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.
    8587    PACPUSLIB_API bool start(const QString& component);
    8688
    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.
    9091    PACPUSLIB_API bool stop();
    9192
    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.
    9696    PACPUSLIB_API bool stop(const QString& component);
    9797
    98     /** Get a 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.
    102102    PACPUSLIB_API ComponentBase* getComponent(const QString& name);
    103103
    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.
    107106    PACPUSLIB_API QStringList getAllComponentsName() const;
    108107
    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 .
    113111    PACPUSLIB_API bool loadPlugin(const QString& filename);
    114112
     
    118116
    119117    bool registerComponent(ComponentBase* addr, const QString& name);
    120     bool registerComponentFactory(ComponentFactoryBase* addr, const QString& type);
     118    bool registerComponentFactory(ComponentFactoryBase * addr, const QString& type);
    121119
    122120    bool unRegisterComponent(const QString& name);
    123121    bool unRegisterComponentFactory(const QString& type);
    124 
    125     // Allow 2 functions to access to private members of ComponentManager
    126     friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString & type);
    127     friend void ComponentFactoryBase::addComponent(const QString & name);
    128122
    129123    /// private constructor accessible only via static create() function
  • trunk/include/Pacpus/kernel/DbiteException.h

    r114 r116  
    1616
    1717#include <Pacpus/kernel/FileLibConfig.h>
     18#include <Pacpus/kernel/PacpusException.h>
    1819
    1920#include <exception>
    2021#include <string>
    2122
    22 #ifdef _MSC_VER
    23 #   pragma warning(push)
    24 #   pragma warning(disable: 4251)
    25 #endif // _MSC_VER
    26 
    2723namespace pacpus {
    2824
    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.
    3227class FILELIB_API DbiteException
    33     : public std::exception
     28    : virtual public PacpusException
    3429{
    3530public:
    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);
    4034
    41     /** Dtor of DbiteException. */
     35    /// Dtor.
    4236    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;
    5337};
    5438
    5539} // namespace pacpus
    5640
    57 #ifdef _MSC_VER
    58 #   pragma warning(pop)
    59 #endif // _MSC_VER
    60 
    6141#endif // DEF_PACPUS_DBITEEXCEPTION_H
  • trunk/include/Pacpus/kernel/FileLibConfig.h

    r76 r116  
    1818#define DEF_PACPUS_FILELIBCONFIG_H
    1919
    20 // Export macro for FileLib DLL for Windows only
     20/// Export macro for FileLib DLL for Windows only
    2121#ifdef WIN32
    2222#   ifdef FILELIB_EXPORTS
  • trunk/include/Pacpus/kernel/Log.h

    r112 r116  
    1515#define DEF_PACPUS_LOG_H
    1616
    17 // Includes, pacpus.
    18 #include <Pacpus/kernel/pacpus.h>
     17#include <Pacpus/kernel/PacpusLibConfig.h>
    1918
    2019namespace pacpus {
     
    4342    static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name))
    4443
    45   /* https://devel.hds.utc.fr/projects/pacpus/ticket/55 */
     44  // https://devel.hds.utc.fr/projects/pacpus/ticket/55
    4645  #define LOG_TRACE(message)          do{LOG4CXX_TRACE(logger, message);} while(false)
    4746  #define LOG_DEBUG(message)          do{LOG4CXX_DEBUG(logger, message);} while(false)
  • trunk/include/Pacpus/kernel/XmlComponentConfig.h

    r91 r116  
    1515#define DEF_PACPUS_XMLCOMPONENTCONFIG_H
    1616
    17 #include <Pacpus/kernel/pacpus.h>
     17#include <Pacpus/kernel/PacpusLibConfig.h>
    1818
    1919#include <QDomElement>
     
    2323class XmlConfigFile;
    2424
    25 /** XmlComponentConfig
    26  * @brief Defines the XML structure of a component.
    27  */
     25/// XmlComponentConfig
     26/// @brief Defines the XML structure of a component.
    2827class PACPUSLIB_API XmlComponentConfig
    2928{
    3029    friend class ComponentManager;
     30
    3131public:
    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);
    3635
    37     /** Dtor of XmlComponentConfig. */
     36    /// Dtor of XmlComponentConfig.
    3837    ~XmlComponentConfig();
    3938
    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.
    4341    void addProperty(const QString& name);
    4442
    45     /** Delete a property from 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.
    4846    int delProperty(const QString& name);
    4947
    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.
    5552    QString getProperty(const QString& name, const QString& defaultValue = QString::null) const;
    5653
    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.
    6258    bool getBoolProperty(const QString& name, bool defaultValue = false) const;
    6359
    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.
    6964    int getIntProperty(const QString& name, int defaultValue = 0) const;
    7065
    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.
    7670    double getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
    7771
    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.
    8275    void setProperty(const QString& name, const QString& value);
    8376
    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.
    8880    bool hasProperty(const QString& name) const;
    8981
  • trunk/include/Pacpus/kernel/XmlConfigFile.h

    r91 r116  
    1515///             - parameters : parameters of the application
    1616///             - components : a list of components to load
    17 ///             
    18 
    1917
    2018#ifndef DEF_PACPUS_XMLCONFIGFILE_H
    2119#define DEF_PACPUS_XMLCONFIGFILE_H
    2220
    23 #include <Pacpus/kernel/pacpus.h>
     21#include <Pacpus/kernel/PacpusLibConfig.h>
    2422#include <Pacpus/kernel/XmlComponentConfig.h>
    2523
  • trunk/include/Pacpus/kernel/pacpus.h

    r76 r116  
    1616#define DEF_PACPUS_H
    1717
     18#include <Pacpus/kernel/PacpusLibConfig.h>
    1819#include <Pacpus/kernel/road_time.h>
    1920
     
    2324#ifndef PACPUS_PI
    2425#   define PACPUS_PI       3.1415926
    25 #endif
    26 
    27 /// Export macro for PacpusLib DLL for Windows only
    28 #ifdef WIN32
    29 #   ifdef PACPUSLIB_EXPORTS
    30 //  make DLL
    31 #       define PACPUSLIB_API __declspec(dllexport)
    32 #   else
    33 //      use DLL
    34 #       define PACPUSLIB_API __declspec(dllimport)
    35 #   endif
    36 #else
    37 //  On other platforms, simply ignore this
    38 #   define PACPUSLIB_API
    3926#endif
    4027
  • trunk/include/Pacpus/kernel/road_time.h

    r91 r116  
    4949/// at the same time.
    5050/// Description of each field is provided inside the structure
    51 struct Initialisation_Time
     51struct ROAD_TIME_API Initialisation_Time
    5252{
    5353    /// Time (extended to micro seconds precision)
Note: See TracChangeset for help on using the changeset viewer.