THYPluginFactory
Overview
The THYPluginFactory factory class is used for unmanaged plugins. This factory is used internally in the Hydra framework to create new instances of the unmanaged plugins.
Use Case
The THYPluginFactory initialization code will automatically be placed in your pluign unit by the wizard whenever you create a new plugin unit, for example:
initialization
THYPluginFactory.Create(HInstance, 'SampleVisualPlugin', Create_SampleVisualPlugin, TSampleVisualPlugin,
1, 23, sRequiredPrivilege, sDescription, sUserData);
Plugin information can be set in plugin wizard, or you can use this code to manually adjust plugin settings such as name or description - please take a look at the constructor description below.
Location
- Unit: Hydra.VCL.PluginFactories.pas
- Ancestry: THYBasePluginFactory | THYPluginFactory
constructor Create (declared in THYBasePluginFactory)
Creates a new instance of the class.
constructor Create
constructor Create (Cardinal, IHYCrossPlatformModule, THYCrossPlatformPluginDescriptor) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; aModuleController: IHYCrossPlatformModule; aDescriptior: THYCrossPlatformPluginDescriptor)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aModuleController: Module controller
- aDescriptior: Reference to a descriptor object that holds plugin data.
constructor Create (Cardinal, string, THYCrossPlatformPluginCreatorFunc, THYCrossPlatformPluginDescriptor) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; const aPluginName: string; aCreatorFunc: THYCrossPlatformPluginCreatorFunc; aDescriptior: THYCrossPlatformPluginDescriptor)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aPluginName: Name of the plugin.
- aCreatorFunc: Function that will be used to create new plugin instances.
- aDescriptior: Reference to a descriptor object that holds plugin data.
constructor Create (Cardinal, string, THYCrossPlatformPluginCreatorFunc, TClass, Integer, Integer, string, string, string) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; const aPluginName: string; aCreatorFunc: THYCrossPlatformPluginCreatorFunc; aPluginClass: TClass; aMajorVersion: Integer; aMinorVersion: Integer; const aRequiredPrivilege: string; const aDescription: string; const aUserData: string)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aPluginName: Name of the plugin.
- aCreatorFunc: Function that will be used to create new plugin instances.
- aPluginClass: Class of the plugin.
- aMajorVersion: Major version number.
- aMinorVersion: Minor version number.
- aRequiredPrivilege: String that describes the privilege needed to use this pluign.
- aDescription: String that holds the plugin description.
- aUserData: String that holds your custom data.
CreateInstance override
Creates a new plugin instance. If the plugin instance supports the IHYVCLPlugin interface, this method will set its host to the provided aHost
parameter. If instance supports the IHYVCLInstanceCounting interface, this method will call its RegisterFactory
method.
Note: You will not call this method directly, to create a new plugin instance you can use one of the THYModuleManager methods, like CreateVisualPlugin
or CreateNonVisualPlugin
.
procedure CreateInstance(const aHost: IHYVCLHost; out anInstance: IInterface)
Parameters:
- aHost: Reference to a host instance.
- anInstance: Reference to a new instance of a plugin.
CreateWrapper protected
function CreateWrapper(aPluginInstance: IDispatch; Descriptor: THYPluginDescriptor): IInterface
Parameters:
- aPluginInstance:
- Descriptor:
Descriptor (declared in THYBasePluginFactory)
Returns the descriptor of the plugin that is represented by the factory.
property Descriptor: THYCrossPlatformPluginDescriptor read
GetInstanceCount protected override
Gets the count of plugin instances that were created by this factory.
function GetInstanceCount: Integer
InstanceCount (declared in THYBasePluginFactory)
Returns the count of plugin instances that were created by this factory.
property InstanceCount: Integer read
InstanceDestroying
If the plugin instance supports the IHYVCLInstanceCounting interface, it will call this method to notify the factory about instance destruction.
procedure InstanceDestroying
ModuleCreateInstance protected virtual
function ModuleCreateInstance: IInterface
Descriptor (declared in THYBasePluginFactory)
Returns the descriptor of the plugin that is represented by the factory.
property Descriptor: THYCrossPlatformPluginDescriptor read
InstanceCount (declared in THYBasePluginFactory)
Returns the count of plugin instances that were created by this factory.
property InstanceCount: Integer read
constructor Create (declared in THYBasePluginFactory)
Creates a new instance of the class.
constructor Create
constructor Create (Cardinal, IHYCrossPlatformModule, THYCrossPlatformPluginDescriptor) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; aModuleController: IHYCrossPlatformModule; aDescriptior: THYCrossPlatformPluginDescriptor)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aModuleController: Module controller
- aDescriptior: Reference to a descriptor object that holds plugin data.
constructor Create (Cardinal, string, THYCrossPlatformPluginCreatorFunc, THYCrossPlatformPluginDescriptor) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; const aPluginName: string; aCreatorFunc: THYCrossPlatformPluginCreatorFunc; aDescriptior: THYCrossPlatformPluginDescriptor)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aPluginName: Name of the plugin.
- aCreatorFunc: Function that will be used to create new plugin instances.
- aDescriptior: Reference to a descriptor object that holds plugin data.
constructor Create (Cardinal, string, THYCrossPlatformPluginCreatorFunc, TClass, Integer, Integer, string, string, string) overload
Creates a new instance of the class.
constructor Create(aModuleInstance: Cardinal; const aPluginName: string; aCreatorFunc: THYCrossPlatformPluginCreatorFunc; aPluginClass: TClass; aMajorVersion: Integer; aMinorVersion: Integer; const aRequiredPrivilege: string; const aDescription: string; const aUserData: string)
Parameters:
- aModuleInstance: Handle of the module instance. By default
HInstance
. - aPluginName: Name of the plugin.
- aCreatorFunc: Function that will be used to create new plugin instances.
- aPluginClass: Class of the plugin.
- aMajorVersion: Major version number.
- aMinorVersion: Minor version number.
- aRequiredPrivilege: String that describes the privilege needed to use this pluign.
- aDescription: String that holds the plugin description.
- aUserData: String that holds your custom data.
CreateInstance override
Creates a new plugin instance. If the plugin instance supports the IHYVCLPlugin interface, this method will set its host to the provided aHost
parameter. If instance supports the IHYVCLInstanceCounting interface, this method will call its RegisterFactory
method.
Note: You will not call this method directly, to create a new plugin instance you can use one of the THYModuleManager methods, like CreateVisualPlugin
or CreateNonVisualPlugin
.
procedure CreateInstance(const aHost: IHYVCLHost; out anInstance: IInterface)
Parameters:
- aHost: Reference to a host instance.
- anInstance: Reference to a new instance of a plugin.
CreateWrapper protected
function CreateWrapper(aPluginInstance: IDispatch; Descriptor: THYPluginDescriptor): IInterface
Parameters:
- aPluginInstance:
- Descriptor:
GetInstanceCount protected override
Gets the count of plugin instances that were created by this factory.
function GetInstanceCount: Integer
InstanceDestroying
If the plugin instance supports the IHYVCLInstanceCounting interface, it will call this method to notify the factory about instance destruction.
procedure InstanceDestroying
ModuleCreateInstance protected virtual
function ModuleCreateInstance: IInterface