InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IK2ServiceProvider Class Referenceabstract

#include <IK2ServiceProvider.h>

Inheritance diagram for IK2ServiceProvider:
IPMUnknownCPMUnknown< IK2ServiceProvider >CServiceProviderCLinkResourceServiceSLCServiceProviderBscDEHDrwEvtSrvcCHLServiceProviderCusCondTxtServiceProviderCusDtLnkDocRespServiceProviderCusDtLnkRespServiceProviderCusDtLnkUISSServiceDocWchServiceProviderGTTxtEdtServiceProviderHypServiceProviderPrtMemHelperStrategyServicePstLstDocServiceProviderSuppUIQuickApplyFilterProviderWRCParagraphComposerServiceProvider

Public Types

enum  { kDefaultIID = IID_IK2SERVICEPROVIDER }
 
enum  InstancePerX { kInstancePerSession, kInstancePerUse, kInstancePerSessionPreload, kInstancePerSessionNoPurge }
 

Public Member Functions

virtual void GetName (PMString *pName)=0
 
virtual ServiceID GetServiceID ()=0
 
virtual bool16 IsDefaultServiceProvider ()=0
 
virtual InstancePerX GetInstantiationPolicy ()=0
 
virtual bool16 HasMultipleIDs () const =0
 
virtual void GetServiceIDs (K2Vector< ServiceID > &serviceIDs)=0
 
virtual IPlugIn::ThreadingPolicy GetThreadingPolicy () const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

The IK2ServiceProvider interface is aggregated by any boss object that wishes to register that it supports a specific service with the IK2ServiceRegistry.

At application startup the service registry finds all boss objects with an IK2ServiceProvider interface and gathers the information about what ServiceID they support, etc. This mechanism is automatic, so all a boss needs to do to be a service is aggregate an implementation of this interface.

Any object that provides a service must implement this interface. A service is a generic way for a plug-in to declare that it provides a service for use by the application. Services are used throughout InDesign. Some examples include scripting, composition, signal/responder, etc.

Member Enumeration Documentation

A service provider can choose to have once instance that is shared by all requests for that service providers (this is the most common case - kInstancePerSession), or a service provider may choose to have a unique instance created on each request for the service provider (kInstancePerUse). "Instance Per Session" service providers are created when first requested and cached by the service registry as long as available memory allows. kInstancePerSessionNoPurge is similar, but will not be purged or unloaded until shutdown (such as "state" data that is expensive or difficult to regenerate). Think carefully before choosing to create a "nopurge" service. kInstancePerSessionPreload will cause a service provider to be constructed and cached at application startup. Furthermore, a "preload" service provider will not be unloaded until application shutdown. Note: Since "preload" service providers are never unloaded, they incur the memory overhead for the service. Therefore "preload" service providers should be avoided, when possible. If you need to be called at startup and/or shutdown, use a kStartupShutdownServiceID.

Member Function Documentation

virtual void IK2ServiceProvider::GetServiceIDs (K2Vector< ServiceID > & serviceIDs)
pure virtual

If the service supports more than on ServiceID, return a list of services supported.

Returns
K2Vector<ServiceID> all supported services

Implemented in DocWchServiceProvider, GTTxtEdtServiceProvider, PstLstDocServiceProvider, CLinkResourceService, CusCondTxtServiceProvider, SLCServiceProvider, CusDtLnkDocRespServiceProvider, CusDtLnkRespServiceProvider, WRCParagraphComposerServiceProvider, and CServiceProvider.

virtual IPlugIn::ThreadingPolicy IK2ServiceProvider::GetThreadingPolicy () const
pure virtual

A service provider can choose if it wants to be instantiated and used by other threads than the main thread. By default the threading policy returned by the base class CServiceProvider is kUnknownThreadingPolicy which means that the service provider will NOT be used by other threads besides the main thread. If a service is designed to be only used exclusively by the main thread it should return kMainThreadOnly. All UI service providers will fall in this category. If a service provider returns kMultipleThreads, it will be instantiated in each worker thread according to its instantiation policy (kInstancePerSession in this case will mean one instance in each thread session).Get the threading policy used for this service.

Returns
the threading policy

Implemented in SLCServiceProvider, CHLServiceProvider, CLinkResourceService, BscDEHDrwEvtSrvc, HypServiceProvider, WRCParagraphComposerServiceProvider, and CServiceProvider.

virtual bool16 IK2ServiceProvider::HasMultipleIDs () const
pure virtual

Support for multiple Service ID's A single service provider may support multiple service IDs. This is a most frequently used for dialog panels that appear in multiple dialogs. If a service does support multiple service ID's and is instance per session, one instance is created per service ID.

Returns
kTrue if this service supports multiple ServiceIDs

Implemented in DocWchServiceProvider, GTTxtEdtServiceProvider, PstLstDocServiceProvider, CLinkResourceService, CusCondTxtServiceProvider, SLCServiceProvider, CusDtLnkDocRespServiceProvider, CusDtLnkRespServiceProvider, WRCParagraphComposerServiceProvider, and CServiceProvider.

virtual bool16 IK2ServiceProvider::IsDefaultServiceProvider ()
pure virtual