Changeset 45 in pacpusframework
- Timestamp:
- Jan 8, 2013, 11:38:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/ComponentFactory.h
r31 r45 1 1 /** 2 2 * 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 * 9 11 */ 10 12 … … 26 28 static pacpus::ComponentFactory<className> sFactory(factoryName) 27 29 28 namespace pacpus 30 namespace pacpus { 31 32 /** ComponentFactory 33 * @brief Use it to interface your components with the application. 34 * 35 * @example 36 * REGISTER_COMPONENT("DummyComponent", DummyComponent); 37 */ 38 template <typename T> 39 class ComponentFactory 40 : public ComponentFactoryBase 29 41 { 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(); 42 public: 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(); 48 50 49 50 51 52 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; 53 55 54 55 56 57 58 59 56 protected: 57 virtual ComponentBase* instantiateComponent(const QString& name); 58 59 private: 60 QString mType; 61 }; 60 62 61 62 63 64 63 template <typename T> 64 ComponentFactory<T>::ComponentFactory(const QString& type) 65 : mType(type) 66 { 65 67 assert(!type.isEmpty()); 66 68 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() const76 {77 return mType;78 }79 80 template<typename T>81 ComponentBase* ComponentFactory<T>::instantiateComponent(const QString& name)82 {83 return new T(name);84 }85 69 } 86 70 71 template<typename T> 72 ComponentFactory<T>::~ComponentFactory() 73 { 74 } 75 76 template <typename T> 77 const QString& ComponentFactory<T>::getType() const 78 { 79 return mType; 80 } 81 82 template<typename T> 83 ComponentBase* ComponentFactory<T>::instantiateComponent(const QString& name) 84 { 85 return new T(name); 86 } 87 88 } // pacpus 89 87 90 #endif // DEF_PACPUS_DBITEEXCEPTION_H
Note:
See TracChangeset
for help on using the changeset viewer.