[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 6 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 7 | /// @date February, 2006
|
---|
| 8 | /// @version $Id: ComponentFactoryBase.h 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
| 12 | /// Purpose: The ComponentFactoryBase class is used to provide an
|
---|
| 13 | /// abstract class to the template ComponentFactory
|
---|
| 14 |
|
---|
| 15 | #ifndef DEF_PACPUS_COMPONENTFACTORYBASE_H
|
---|
| 16 | #define DEF_PACPUS_COMPONENTFACTORYBASE_H
|
---|
| 17 |
|
---|
[196] | 18 | #include <Pacpus/kernel/PacpusLibConfig.h>
|
---|
[89] | 19 |
|
---|
[290] | 20 | #include <boost/smart_ptr/shared_ptr.hpp>
|
---|
| 21 | //#include <boost/smart_ptr/weak_ptr.hpp>
|
---|
[288] | 22 |
|
---|
[89] | 23 | class QString;
|
---|
| 24 |
|
---|
[288] | 25 | namespace pacpus
|
---|
| 26 | {
|
---|
[89] | 27 |
|
---|
| 28 | class ComponentBase;
|
---|
| 29 |
|
---|
[288] | 30 | typedef boost::shared_ptr<ComponentBase> ComponentSharedPointer;
|
---|
| 31 | //typedef boost::weak_ptr<ComponentBase> ComponentWeakPointer;
|
---|
| 32 |
|
---|
| 33 | class ComponentManager;
|
---|
| 34 |
|
---|
[89] | 35 | /** ComponentFactoryBase
|
---|
| 36 | * @brief Provide an abstract class to the template ComponentFactory.
|
---|
| 37 | */
|
---|
| 38 | class PACPUSLIB_API ComponentFactoryBase
|
---|
| 39 | {
|
---|
| 40 | friend class ComponentManager;
|
---|
[288] | 41 |
|
---|
[89] | 42 | public:
|
---|
| 43 | /** Ctor of ComponentFactoryBase. */
|
---|
| 44 | ComponentFactoryBase();
|
---|
| 45 | /** Dtor of ComponentFactoryBase. */
|
---|
| 46 | virtual ~ComponentFactoryBase();
|
---|
| 47 |
|
---|
| 48 | protected:
|
---|
| 49 | /** Create a new component having @em name as component name.
|
---|
| 50 | * @param name Name of the instantiated component.
|
---|
| 51 | * @return Pointer on the newly created component, you become the owner of its lifetime.
|
---|
| 52 | */
|
---|
[288] | 53 | virtual ComponentSharedPointer instantiateComponent(QString const& name) = 0;
|
---|
[89] | 54 |
|
---|
| 55 | /** Register a new factory.
|
---|
| 56 | * @param addr Address of the factory.
|
---|
| 57 | * @param type Name of the type created by the factory.
|
---|
| 58 | */
|
---|
[288] | 59 | void addFactory(ComponentFactoryBase* addr, QString const& type);
|
---|
[89] | 60 |
|
---|
| 61 | /** Add a new component.
|
---|
| 62 | * @param name Name of the new component.
|
---|
| 63 | */
|
---|
[288] | 64 | void createComponent(QString const& name);
|
---|
[89] | 65 |
|
---|
| 66 | private:
|
---|
| 67 | ComponentManager* mgr_;
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | } // namespace pacpus
|
---|
| 71 |
|
---|
| 72 | #endif
|
---|