InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Utils< IFace > Class Template Reference

#include <Utils.h>

Public Member Functions

 Utils ()
 
 ~Utils ()
 
IFace * operator-> () const
 
 operator IFace * ()
 
bool16 Exists () const
 
IFace * QueryUtilInterface ()
 

Detailed Description

template<class IFace>
class Utils< IFace >

This is a helper class for calling methods in interfaces on the kUtilsBoss. The Utils boss is an easy way access common utilities interfaces.

If you want to do a one-line call on a method in a utility interface, you can do this: Utils<IFooUtils>()->MyFooMethod();

That one line will query the utils boss for the right interface, then call the MyFooMethod() on that interface.

If you want to use a utility interface in several places, it is more efficient to get the interface once, save it in an InterfacePtr, and call it from there. For example:

InterfacePtr<IFooUtils> fooUtils(Utils<IFooUtils>());

This does the QueryInterface() and Release just once, which is better than once per call if you are making many calls.

Constructor & Destructor Documentation

template<class IFace>
Utils< IFace >::Utils()
inline

Construct a Utils helper object, which will Query for the <IFace> Interface on the utils boss.

template<class IFace>
Utils< IFace >::~Utils()
inline

Destruct a Utils helper object, which will Release the <IFace> interface on the utils boss.

Member Function Documentation

template<class IFace>
bool16 Utils< IFace >::Exists () const
inline

Returns true if the utility interface is present. Call this before using the utility interface if it's possible that the plug-in that supplies the interface has been removed.

Returns
bool kTrue if the interface exists, kFalse otherwise
template<class IFace>
Utils< IFace >::operator IFace * ()
inline

Return a pointer to the interface. The interface is good only until the Utils object is destructed, since the destructor will Release the interface.

Returns
pointer to the utility interface
template<class IFace>
IFace* Utils< IFace >::operator-> () const
inline

Return a pointer to the interface. The interface is good only until the Utils object is destructed, since the destructor will Release the interface.

Returns
pointer to the utility interface
template<class IFace>
IFace* Utils< IFace >::QueryUtilInterface ()
inline

Returns a referenced pointer to the utility interface. Caller is resposible for calling Release() on the interface that is returned. Use this method if you want to get a pointer to a utility interface that will stay good after the Utils object has been destructed. Example call: InterfacePtr<IFace>myUtil( Utils<IFace>().QueryUtilInterface() );

Returns
referenced pointer to the utility interface