Changeset 45 in pacpusframework


Ignore:
Timestamp:
Jan 8, 2013, 11:38:03 PM (12 years ago)
Author:
sgosseli
Message:

Minor: coding style and license header.

File:
1 edited

Legend:

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

    r31 r45  
    11/**
    22 *
    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  *
     3 * This file is part of the PACPUS framework distributed under the
     4 * CECILL-C License, Version 1.0.
     5 *
     6 * @author  Gerald Dherbomez
     7 * @date    December, 2012
     8 * @version $Id$
     9 * @copyright Copyright (c) UTC/CNRS Heudiasyc 2005 - 2013. All rights reserved.
     10 *
    911 */
    1012
     
    2628  static pacpus::ComponentFactory<className> sFactory(factoryName)
    2729
    28 namespace pacpus
     30namespace pacpus {
     31
     32/** ComponentFactory
     33 * @brief Use it to interface your components with the application.
     34 *
     35 * @example
     36 *   REGISTER_COMPONENT("DummyComponent", DummyComponent);
     37 */
     38template <typename T>
     39class ComponentFactory
     40    : public ComponentFactoryBase
    2941{
    30   /** ComponentFactory
    31    * @brief Use it to interface your components with the application.
    32    *
    33    * @example
    34    *   REGISTER_COMPONENT("DummyComponent", DummyComponent);
    35    */
    36   template <typename T>
    37   class ComponentFactory
    38     : public ComponentFactoryBase
    39   {
    40     public:
    41       /** Ctor of ComponentFactory, initialize the factory of the components of type @em T.
    42        * @param type Name of the type of the components.
    43        */
    44       ComponentFactory(const QString& type);
    45      
    46       /** Dtor of ComponentFactory. */
    47       virtual ~ComponentFactory();
     42public:
     43    /** Ctor of ComponentFactory, initialize the factory of the components of type @em T.
     44     * @param type Name of the type of the components.
     45     */
     46    ComponentFactory(const QString& type);
     47   
     48    /** Dtor of ComponentFactory. */
     49    virtual ~ComponentFactory();
    4850
    49       /** Get the name of the type of the components.
    50        * @return Name of the type of the components.
    51        */
    52       const QString& getType() const;
     51    /** Get the name of the type of the components.
     52     * @return Name of the type of the components.
     53     */
     54    const QString& getType() const;
    5355
    54     protected:
    55       virtual ComponentBase* instantiateComponent(const QString& name);
    56      
    57     private:
    58       QString mType;
    59   };
     56protected:
     57    virtual ComponentBase* instantiateComponent(const QString& name);
     58 
     59private:
     60    QString mType;
     61};
    6062
    61   template <typename T>
    62   ComponentFactory<T>::ComponentFactory(const QString& type)
    63     : mType(type)
    64   {
     63template <typename T>
     64ComponentFactory<T>::ComponentFactory(const QString& type)
     65  : mType(type)
     66{
    6567    assert(!type.isEmpty());
    6668    addFactory(this, mType);
    67   }
    68 
    69   template<typename T>
    70   ComponentFactory<T>::~ComponentFactory()
    71   {
    72   }
    73 
    74   template <typename T>
    75   const QString& ComponentFactory<T>::getType() const
    76   {
    77     return mType;
    78   }
    79 
    80   template<typename T>
    81   ComponentBase* ComponentFactory<T>::instantiateComponent(const QString& name)
    82   {
    83     return new T(name);
    84   }
    8569}
    8670
     71template<typename T>
     72ComponentFactory<T>::~ComponentFactory()
     73{
     74}
     75
     76template <typename T>
     77const QString& ComponentFactory<T>::getType() const
     78{
     79    return mType;
     80}
     81
     82template<typename T>
     83ComponentBase* ComponentFactory<T>::instantiateComponent(const QString& name)
     84{
     85    return new T(name);
     86}
     87
     88} // pacpus
     89
    8790#endif // DEF_PACPUS_DBITEEXCEPTION_H
Note: See TracChangeset for help on using the changeset viewer.