ComponentPlugin< T, Factory > Class Template Reference

#include <Pt/Cosmo/ComponentPlugin.h>

Default component plugin. More...

Inherits IComponentPlugin.

Public Member Functions

 ComponentPlugin (const char *featureId, const char *classId, const char *info, ComponentMode mode=ComponentMode::None, const Factory &factory=ComponentFactory< T >())
 Constructor. More...
 
 ~ComponentPlugin ()
 Destructor.
 
template<typename I >
void registerInterface ()
 Registers a component interface.
 
template<typename I >
void registerInterface (I *(T::*getter)())
 Registers a component interface.
 
void registerDependency (const char *featureId)
 Registers the dependency to another component.
 
void registerFeatureId (const char *featureId)
 Registers a feature ID.
 
const IEnumerable< const char * > & dependencies () const
 Returns the feature IDs of the dependencies.
 
ComponentMode mode () const
 Returns the component mode.
 
const char * info () const
 Returns the info string of the component.
 
Componentcreate (const IComponentDeclaration *decl)
 Creates a component instance.
 
void destroy (Component *instance)
 Destroys a component instance.
 
bool hasFeatureId (const char *featureId) const
 Returns true if the given feature ID is implemented. More...
 
const IEnumerable< const char * > & featureIds () const
 Returns the implemented feature IDs.
 
const char * classId () const
 Returns the class ID of the component.
 
template<typename I >
bool hasInterface () const
 Returns true if the interface is implemented.
 
template<typename I >
I * queryInterface (Component &c) const
 Returns the interface or null if not implemented. More...
 

Protected Member Functions

virtual bool onHasFeatureId (const char *featureId) const override
 Returns true if the given feature ID is implemented.
 
virtual const IEnumerable< const char * > & onGetFeatureIds () const override
 Returns the implemented feature IDs.
 
virtual const char * onGetClassId () const override
 Returns the class ID of the component.
 
bool onHasInterface (const std::type_info &ti) const override
 Returns true if the interface is implemented.
 
virtual IUnknownonQueryInterface (Component &c, const std::type_info &ti) const override
 Returns the interface or null if the interface is not implemented.
 
virtual void onAttach (IComponentManager &cm, const std::string &instance) override
 The plugin is attached to a component manager.
 
virtual void onDetach (IComponentManager &cm, const std::string &instance) override
 The plugin is detached from a component manager.
 
virtual void onDetach (IComponentManager &cm) override
 The plugin is detached from a component manager.
 
virtual const IEnumerable< const char * > & onGetDependencies () const override
 Returns the feature IDs of the depencies.
 
virtual ComponentMode onGetMode () const override
 Returns the component mode.
 
virtual const char * onGetInfo () const override
 Returns the info string of the component.
 
virtual ComponentonCreate () override
 Creates a component instance.
 
virtual void onDestroy (Component *instance) override
 Destroys a component instance.
 

Detailed Description

template<typename T, typename Factory = ComponentFactory<T>>
class Pt::Cosmo::ComponentPlugin< T, Factory >

Implements the IComponentPlugin interface for a concrete component class T. Provides registration of interfaces, dependencies, and feature IDs. Uses a configurable factory (default: ComponentFactory) to create and destroy component instances.

Constructor & Destructor Documentation

◆ ComponentPlugin()

ComponentPlugin ( const char *  featureId,
const char *  classId,
const char *  info,
ComponentMode  mode = ComponentMode::None,
const Factory &  factory = ComponentFactory< T >() 
)

The featureId is the primary feature ID used to create the component from application code, info is the implementation info string and the mode flags indicate various operation modes such as auto-start.

Member Function Documentation

◆ hasFeatureId()

bool hasFeatureId ( const char *  featureId) const
inherited
Parameters
featureIdThe feature ID to check.

◆ queryInterface()

I * queryInterface ( Component c) const
inherited
Parameters
cThe component instance to query.