Changeset 288 in pacpusframework for trunk/include/Pacpus/kernel/ComponentManager.h


Ignore:
Timestamp:
03/26/14 21:27:30 (10 years ago)
Author:
Marek Kurdej
Message:

Using boost::shared_ptr for storing components.

File:
1 edited

Legend:

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

    r207 r288  
    2828#include <QPluginLoader>
    2929
    30 namespace pacpus {
     30namespace pacpus
     31{
    3132
    3233class ComponentBase;
    3334
    3435/// @todo Documentation
    35 typedef QMap<QString, ComponentBase *> ComponentMap;
     36typedef QMap<QString, ComponentSharedPointer> ComponentMap;
    3637/// @todo Documentation
    37 typedef QMap<QString, ComponentFactoryBase *> FactoryMap;
     38typedef QMap<QString, ComponentFactoryBase* > FactoryMap;
    3839
    3940/// Singleton recording the components and managing them.
     
    5960    struct destroyer {
    6061        /// Invokes ComponentManager::destroy() method if @b mgr pointer is not null.
    61         void operator()(ComponentManager * mgr) const
     62        void operator()(ComponentManager* mgr) const
    6263        {
    6364            if (!mgr) {
     
    7273     * @return Number of components loaded by the manager.
    7374     */
    74     std::size_t loadComponents(const QString& file);
     75    std::size_t loadComponents(QString const& file);
    7576
    7677    /** Start all the components
     
    8384     * @return True if the component exists and has been started, otherwise false.
    8485     */
    85     bool start(const QString & component);
     86    bool start(QString const& component);
    8687
    8788    /** Stop all the components
     
    9495     * @return True if the component has been stopped, otherwise false.
    9596     */
    96     bool stop(const QString& component);
     97    bool stop(QString const& component);
    9798
    9899    /** Get a pointer to the component referred by @em name.
     
    100101     * @return Pointer to the component if it exists, otherwise @em NULL.
    101102     */
    102     ComponentBase* getComponent(const QString& name);
     103    ComponentSharedPointer getComponent(QString const& name);
    103104
    104105    /** Get the list of all the names of the component known by the manager.
     
    111112     * @return True if the plugin has been loaded, otherwise false.
    112113     */
    113     bool loadPlugin(const QString& filename);
     114    bool loadPlugin(QString const& filename);
    114115
    115116private:
    116     bool stop(ComponentBase* component) const;
     117    bool stop(ComponentSharedPointer component) const;
    117118
    118119    /// Create a new component of type 'type' and with the name 'name'
    119     bool createComponent(const QString& type, const QString& name);
     120    bool createComponent(QString const& type, QString const& name);
    120121
    121     bool checkComponent(const QString & componentName);
    122     bool checkComponentInput(const QString & componentName, const QString & inputName);
    123     bool checkComponentOutput(const QString & componentName, const QString & outputName);
     122    bool checkComponent(QString const& componentName);
     123    bool checkComponentInput(QString const& componentName, QString const& inputName);
     124    bool checkComponentOutput(QString const& componentName, QString const& outputName);
    124125
    125     bool createConnection(const QString& type, const QString& name, const QString& , int );
     126    bool createConnection(QString const& type, QString const& name, QString const& , int );
    126127
    127     bool registerComponent(ComponentBase* addr, const QString& name);
    128     bool registerComponentFactory(ComponentFactoryBase* addr, const QString& type);
     128    bool registerComponent(ComponentSharedPointer addr, QString const& name);
     129    bool registerComponentFactory(ComponentFactoryBase* addr, QString const& type);
    129130
    130     bool unregisterComponent(const QString& name);
    131     bool unregisterComponentFactory(const QString& type);
     131    bool unregisterComponent(QString const& name);
     132    bool unregisterComponentFactory(QString const& type);
    132133
    133134    // Allow 2 functions to access to private members of ComponentManager
    134     friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString & type);
    135     friend void ComponentFactoryBase::addComponent(const QString & name);
     135    friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type);
     136    friend void ComponentFactoryBase::createComponent(QString const& name);
    136137
    137138    /// private constructor accessible only via static create() function
Note: See TracChangeset for help on using the changeset viewer.