InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UIDRef Class Reference

#include <UIDRef.h>

Public Types

typedef base_type data_type
 

Public Member Functions

 UIDRef (IDataBase *db, UID id)
 
IDataBaseGetDataBase () const
 
UID GetUID () const
 
void ResetUID (UID newUID)
 
bool16 operator== (const UIDRef &other) const
 
bool16 operator!= (const UIDRef &other) const
 
bool16 operator< (const UIDRef &other) const
 
bool16 operator! () const
 
 operator void * () const
 
bool16 ExistsInDB () const
 
IPMUnknownInstantiate (PMIID iid) const
 

Static Public Attributes

static const UIDRef gNull
 

Detailed Description

UIDRef

A UIDRef is a reference to a persistent object. Persistent objects are created in databases, by creating new UIDs. An open InDesign document is associated with a database, and the persistent objects stored with the document are managed and maintained by the database. If you have a pointer to the object in memory (for instance, a pointer to an interface of the object), that pointer is only good as long as the object is in memory. When it's released, the pointer can no longer be used to refer to the object. A UID is a persistent reference to an object that is good across instantations, and can be stored in the document as well. A UIDRef is a pair of <database, UID> that gives us a way to refer to an object as long as the document it is in is open.

Member Typedef Documentation

This declares that UIDRef's have binary copy semantics. This means they can be copied byte-wise if necessary for performance reasons.

Constructor & Destructor Documentation

UIDRef::UIDRef (IDataBasedb,
UID id 
)
inline

Create a new UIDRef to the specified object in the database.

Member Function Documentation

bool16 UIDRef::ExistsInDB () const
inline
            ---- This function returns kTrue if the UIDRef is valid

                and the UID exists in its database. Else returns kFalse

                Common usage is to check and see if a UID can be

                instantiated.

                e.g.        

                <pre>

                UID myUIDRef(aDB, aUID);

                if (myUIDRef.IsExistsInDB() {

OK to instantiate UIDRef InterfacePtr<ISomeInterface> theIFace(myUIDRef, IID_ISOMEINTERFACE); theIFace->DoWork(); } else { UID ref is invalid or does not exist myUIDRef = UIDRef::gNull }

Returns
kTrue if the UIDRef is valid and the UID exists in its database
IDataBase* UIDRef::GetDataBase (void ) const
inline

Get the database.

Returns
IDataBase* the database the UIDRef is in
UID UIDRef::GetUID () const
inline

Get the UID

Returns
UID of the UIDRef
IPMUnknown * UIDRef::Instantiate (PMIID iid) const
inline

Get a pointer to the object in memory, reading it from disk if necessary.

Parameters
iidwhich interface of the object to return (use IID_IUNKNOWN if you don't care).
Returns
IPMUnknown* a pointer to the requested interface of the object, or nil if the object couldn't be found.
UIDRef::operator void * () const
inline

Returns a nil pointer if the UIDRef is nil, non-nil otherwise.

Returns
nil pointer if the UIDRef has nil database or kInvalidUID.
bool16 UIDRef::operator! () const
inline

Test to see if the UIDRef is nil

Returns
kTrue if the UIDRef has nil database or kInvalidUID.
bool16 UIDRef::operator!= (const UIDRefother) const
inline

Compare two UIDRefs for inequality

Parameters
otherthe UIDRef to compare to
Returns
kTrue if the UIDRefs are not the same
bool16 UIDRef::operator< (const UIDRefother) const
inline

Compare two UIDRefs for inequality

Parameters
otherthe UIDRef to compare to
Returns
kTrue if this < other
bool16 UIDRef::operator== (const UIDRefother) const
inline

Compare two UIDRefs for equality

Parameters
otherthe UIDRef to compare to
Returns
kTrue if the UIDRefs are the same
void UIDRef::ResetUID (UID newUID)
inline

Reset the value of the UIDRef, so it refers to a different object in the same database.

Parameters
newUIDnew value for the UIDRef.