Changeset 146 in pacpusframework for branches/2.0-beta1/include


Ignore:
Timestamp:
07/31/13 11:20:11 (11 years ago)
Author:
Marek Kurdej
Message:

Update: refactoring in XmlConfigFile.
Added: attributes 'prefix', 'postfix', 'extension' in <parameters>.
Example: <parameters prefix="" postfix="_d" extension="dll">

Location:
branches/2.0-beta1/include/Pacpus/kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/include/Pacpus/kernel/ComponentManager.h

    r89 r146  
    3838
    3939/// Singleton recording the components and managing them.
    40 class ComponentManager
     40class PACPUSLIB_API ComponentManager
    4141{
    4242    friend class ComponentBase;
     
    4545    /// @returns a pointer to the ComponentManager object
    4646    /// @deprecated Use getInstance()
    47     PACPUS_DEPRECATED_MSG( static PACPUSLIB_API ComponentManager * create(), "use 'getInstance()'" );
     47    PACPUS_DEPRECATED_MSG( static ComponentManager * create(), "use 'getInstance()'" );
    4848
    4949    /// Returns an instance of the singleton ComponentManager class.
    5050    /// @returns Pointer to the ComponentManager singleton.
    51     static PACPUSLIB_API ComponentManager* getInstance();
     51    static ComponentManager* getInstance();
    5252
    5353    /// Destroys the ComponentManager singleton.
    5454    ///
    5555    /// After this call, every pointer to the ComponentManager becomes invalid.
    56     static PACPUSLIB_API void destroy();
     56    static void destroy();
    5757
    5858    /// Automatic deleter class.
     
    7272     * @return Number of components loaded by the manager.
    7373     */
    74     PACPUSLIB_API std::size_t loadComponents(const QString& file);
     74    std::size_t loadComponents(const QString& file);
    7575
    7676    /** Start all the components
    7777     * @return True if all the component has been started, otherwise false.
    7878     */
    79     PACPUSLIB_API bool start();
     79    bool start();
    8080
    8181    /** Start only the component passed in parameter.
     
    8383     * @return True if the component exists and has been started, otherwise false.
    8484     */
    85     PACPUSLIB_API bool start(const QString& component);
     85    bool start(const QString& component);
    8686
    8787    /** Stop all the components
    8888     * @return True if all the component has been stopped, otherwise false.
    8989     */
    90     PACPUSLIB_API bool stop();
     90    bool stop();
    9191
    9292    /** Stop only the component passed in parameter.
     
    9494     * @return True if the component has been stopped, otherwise false.
    9595     */
    96     PACPUSLIB_API bool stop(const QString& component);
     96    bool stop(const QString& component);
    9797
    9898    /** Get a pointer to the component referred by @em name.
     
    100100     * @return Pointer to the component if it exists, otherwise @em NULL.
    101101     */
    102     PACPUSLIB_API ComponentBase* getComponent(const QString& name);
     102    ComponentBase* getComponent(const QString& name);
    103103
    104104    /** Get the list of all the names of the component known by the manager.
    105105     * @return List of all the component's name.
    106106     */
    107     PACPUSLIB_API QStringList getAllComponentsName() const;
     107    QStringList getAllComponentsName() const;
    108108
    109109    /** Load a new plugin from the file filename (it may be a .so/.dll file)
     
    111111     * @return True if the plugin has been loaded, otherwise false.
    112112     */
    113     PACPUSLIB_API bool loadPlugin(const QString& filename);
     113    bool loadPlugin(const QString& filename);
    114114
    115115private:
     116    bool stop(ComponentBase* component) const;
     117
    116118    /// Create a new component of type 'type' and with the name 'name'
    117119    bool createComponent(const QString& type, const QString& name);
     
    122124    bool registerComponentFactory(ComponentFactoryBase* addr, const QString& type);
    123125
    124     bool unRegisterComponent(const QString& name);
    125     bool unRegisterComponentFactory(const QString& type);
     126    bool unregisterComponent(const QString& name);
     127    bool unregisterComponentFactory(const QString& type);
    126128
    127129    // Allow 2 functions to access to private members of ComponentManager
  • branches/2.0-beta1/include/Pacpus/kernel/PacpusEvent.h

    r131 r146  
    4242
    4343public:
    44     PacpusEvent(PacpusEventType type, road_time_t t = road_time(), road_timerange_t tr = 0):QEvent(QEvent::Type(type)),t_(t),tr_(tr) {}
    45     virtual ~PacpusEvent() {}
     44    PacpusEvent(PacpusEventType type, road_time_t t = road_time(), road_timerange_t tr = 0)
     45        : QEvent(QEvent::Type(type))
     46        , t_(t)
     47        , tr_(tr)
     48    {}
     49    virtual ~PacpusEvent()
     50    {}
    4651
    47     virtual QDataStream& streamOut(QDataStream& out) {return out;}; // NOTE virtual pure ??
    48     virtual QDataStream& streamIn(QDataStream& in) {return in;};
     52    // NOTE virtual pure ??
     53    virtual QDataStream& streamOut(QDataStream& out)
     54    {
     55        return out;
     56    }
     57    virtual QDataStream& streamIn(QDataStream& in)
     58    {
     59        return in;
     60    }
    4961
    50 public: // TODO make protected
     62protected: // TODO make protected
    5163    road_time_t t_;
    5264    road_timerange_t tr_;
     
    6375    QDataStream& streamIn(QDataStream& in) {return in >> (quint64&)t_ >> tr_ /*>> data_*/;}
    6476
    65 public: // TODO make protected
     77protected:
    6678    T data_;
    6779};
     
    7082{
    7183public:
    72     PacpusGenericEvent(PacpusEventType type, char* data, size_t size):PacpusEvent(type) {
    73         data_ = (char*)malloc(size);
     84    PacpusGenericEvent(PacpusEventType type, char* data, size_t size)
     85        : PacpusEvent(type)
     86    {
     87        data_ = new char[size];
    7488        memcpy(data_,data,size);
    7589        _size = size;
    7690
    7791    }
    78     virtual ~PacpusGenericEvent() {free(data_);}
     92   
     93    virtual ~PacpusGenericEvent()
     94    {
     95        delete[] data_;
     96    }
     97
    7998    char* data_;
    8099    size_t _size;
  • branches/2.0-beta1/include/Pacpus/kernel/XmlConfigFile.h

    r89 r146  
    2727
    2828#include <QDomElement>
     29#include <QFile>
    2930#include <QMutex>
    3031#include <QStringList>
     
    4748    /// @todo Documentation
    4849    static void destroy();
     50
     51    /// @returns a list of all names of components declared in the XML tree
     52    QStringList getAllComponentsNames() const;
    4953    /// @todo Documentation
    50     QDomElement getComponent(QString name);
    51     /// @returns a list of all names of components declared in the XML tree
    52     QStringList getAllComponentsNames();
     54    QDomElement getComponent(QString name) const;
     55   
     56    // TODO: QStringList getAllConnectionsNames() const;
     57    QDomElement getConnection(QString connectionName) const;
     58
    5359    /// @todo Documentation
    54     QStringList getAllPlugins();
     60    QStringList getAllPluginsNames();
     61   
    5562    /// @todo Documentation
    5663    int loadFile(QString fileName);
    57 
    58     QDomNodeList getAllComponents();
    59 
    60     QDomNodeList getAllConnections();
    61 
    62     QDomElement getConnection(QString connectionName);
    6364
    6465    /// @todo Documentation
    6566    /// not used
    6667    void saveFile(QString fileName);
     68   
    6769    /// @todo Documentation
    6870    /// not used
    6971    void addComponent(QDomElement component);
     72   
    7073    /// @todo Documentation
     74    /// @deprecated Use removeComponent()
    7175    /// not used
    72     void delComponent(QDomElement component);
     76    PACPUS_DEPRECATED_MSG( void delComponent(QDomElement component), "use removeComponent()" );
     77    void removeComponent(QDomElement component);
    7378
    7479protected:
     80    QDomNodeList getAllComponents() const;
     81    QDomNodeList getAllConnections() const;
     82    QDomNodeList getAllPlugins();
     83
    7584private:
    7685    XmlConfigFile();
    7786    ~XmlConfigFile();
    7887
    79     static XmlConfigFile * _xmlConfigFile;
    80    
    8188    QDomElement createComponent(QString name);
    8289
     90    QString libraryExtension() const;
     91    QString libraryPrefix() const;
     92    QString libraryPostfix() const;
     93
    8394private:
    84     QDomDocument _document;
    85     QFile * _file;
    86     QMutex _mutex;
     95    static XmlConfigFile * m_xmlConfigFile;
     96   
     97    QDomDocument m_document;
     98    QFile m_file;
     99    QMutex m_mutex;
    87100
    88     int _numberOfComponents;
     101    QString m_libraryExtension;
     102    QString m_libraryPrefix;
     103    QString m_libraryPostfix;
     104   
     105    int m_numberOfComponents;
    89106};
    90107
Note: See TracChangeset for help on using the changeset viewer.