IComponentPlugin.h
1
26
27#ifndef COSMO_COMPONENT_PLUGIN_INTERFACE_H
28#define COSMO_COMPONENT_PLUGIN_INTERFACE_H
29
30#include <Pt/Cosmo/ComponentMode.h>
31#include <Pt/Cosmo/IComponentType.h>
32#include <Pt/Cosmo/IEnumerable.h>
33
34namespace Pt {
35
36namespace Cosmo {
37
38class Component;
40
51{
52 friend class IComponentManager;
53
54 public:
58 {}
59
63
67
70 const char* info() const;
71
75
78 void destroy(Component* instance);
79
80 protected:
83 virtual void onAttach(IComponentManager& cm, const std::string& instance) = 0;
84
87 virtual void onDetach(IComponentManager& cm, const std::string& instance) = 0;
88
91 virtual void onDetach(IComponentManager& cm) = 0;
92
95 virtual const IEnumerable<const char*>& onGetDependencies() const = 0;
96
99 virtual ComponentMode onGetMode() const = 0;
100
103 virtual const char* onGetInfo() const = 0;
104
107 virtual Component* onCreate() = 0;
108
111 virtual void onDestroy(Component* instance) = 0;
112};
113
114} // namespace Cosmo
115
116} // namespace Pt
117
118#include <Pt/Cosmo/Component.h>
119
120namespace Pt {
121
122namespace Cosmo {
123
128
129
131{
132 return onGetMode();
133}
134
135
136inline const char* IComponentPlugin::info() const
137{
138 return onGetInfo();
139}
140
141
143{
144 Component* component = this->onCreate();
145 component->init(this, decl);
146 return component;
147}
148
149
151{
152 onDestroy(instance);
153}
154
155} // namespace Cosmo
156
157} // namespace Pt
158
159#endif
Component flags.
Definition ComponentMode.h:45
Component base class.
Definition Component.h:52
void init(const IComponentType *type, const IComponentDeclaration *decl)
Initializes the component.
Component instance declaration.
Definition IComponentDeclaration.h:45
Component manager interface.
Definition IComponentManager.h:55
Component plugin interface.
Definition IComponentPlugin.h:51
void destroy(Component *instance)
Destroys a component instance.
Definition IComponentPlugin.h:150
const IEnumerable< const char * > & dependencies() const
Returns the feature IDs of the dependencies.
Definition IComponentPlugin.h:124
virtual ComponentMode onGetMode() const =0
Returns the component mode.
Component * create(const IComponentDeclaration *decl)
Creates a component instance.
Definition IComponentPlugin.h:142
virtual void onDestroy(Component *instance)=0
Destroys a component instance.
ComponentMode mode() const
Returns the component mode.
Definition IComponentPlugin.h:130
virtual const IEnumerable< const char * > & onGetDependencies() const =0
Returns the feature IDs of the depencies.
virtual ~IComponentPlugin()
Destructor.
Definition IComponentPlugin.h:57
virtual const char * onGetInfo() const =0
Returns the info string of the component.
virtual void onDetach(IComponentManager &cm, const std::string &instance)=0
The plugin is detached from a component manager.
virtual Component * onCreate()=0
Creates a component instance.
const char * info() const
Returns the info string of the component.
Definition IComponentPlugin.h:136
virtual void onAttach(IComponentManager &cm, const std::string &instance)=0
The plugin is attached to a component manager.
virtual void onDetach(IComponentManager &cm)=0
The plugin is detached from a component manager.
Component interface query.
Definition IComponentType.h:50
Enumerable interface.
Definition IEnumerable.h:58
Cosmo Component Model.
Definition Api.h:53
Core module.
Definition Allocator.h:33