![]() | InDesign SDK 20.5 |
#include <InterfacePtr.h>
Public Types | |
| typedef object_type | data_type |
Public Member Functions | |
| InterfacePtr (IFace *p) | |
| InterfacePtr (const IPMUnknown *p, PMIID iid) | |
| InterfacePtr (const IPMUnknown *p, const UseDefaultIID &) | |
| InterfacePtr (void) | |
| template<class OtherType > | |
| InterfacePtr (const InterfacePtr< OtherType > &p) | |
| InterfacePtr (const InterfacePtr< IFace > &p) | |
| InterfacePtr (InterfacePtr< IFace > &&p) noexcept | |
| template<class OtherType > | |
| InterfacePtr< IFace > & | operator= (const InterfacePtr< OtherType > &p) |
| InterfacePtr< IFace > & | operator= (const InterfacePtr< IFace > &p) |
| InterfacePtr< IFace > & | operator= (InterfacePtr< IFace > &&p) noexcept |
| InterfacePtr (IDataBase *db, UID uid, PMIID iid) | |
| InterfacePtr (IDataBase *db, UID uid, const UseDefaultIID &) | |
| InterfacePtr (const UIDRef &ref, PMIID iid) | |
| InterfacePtr (const UIDRef &ref, const UseDefaultIID &) | |
| operator IFace * () const | |
| IFace * | operator-> () const |
| bool16 | operator! () const |
| IFace * | forget () |
| IFace * | get () const |
| void | reset (IFace *p=0) |
| void | swap (InterfacePtr< IFace > &other) noexcept |
InterfacePtr is a smart pointer class that simplifies the work with interface pointers. It guarantees that Release() will be called on an acquired interface and AddRef() when sharing the ownership.
| typedef object_type InterfacePtr< IFace >::data_type |
Allows containment of InterfacePtr in K2Vector.
| inlineexplicit |
This constructor will take ownership of the specified interface. AddRef is NOT called, but
Release will be called in the destructor. This functionality is best described as an Attach(). Most of the time, you do not want to use this constructor, but the ones with two parameters which do call AddRef. Do not use p after this call since it may be invalid after the InterfacePtr goes out of scope. Use this constructor when you've called a function that returns an AddRef'd pointer – e.g., QuerySpread(), QueryApplication(), etc.
| p | [IN] - interface pointer that we attach to. |
| inline |
Use this constructor if you have one interface on a boss and want another one. Addref is called
on the boss, so it is still safe to use the p after the InterfacePtr goes out of scope.
| p | [IN] - interface to use for query. |
| iid | [IN] - IID of the interface we want. |
| inline |
This constructor is similar to the one directly above. It is more convenient but will only compile if IFace::kDefaultIID is defined
| p | [IN] - interface to use for query. |
| inline |
Default constructor: construct a nil InterfacePtr
| inline |
Constructor that enables InterfacePtr<const IFoo> to be constructed from an InterfacePtr<IFoo>.
| inline |
Copy constructor. Increments the ref count of p by one. We define this to prevent the
compiler from generating a bitwise copying version (template members do not suffice).
| p | [IN] - InterfacePtr to be copied. |
| inline |
Constructs an InterfacePtr from an object from a database.
| db | [IN] - Database to instantiate from |
| uid | [IN] - UID of the boss. |
| iid | [IN] - IID of the desired interface from the boss. |
| inline |
Constructs an InterfacePtr from an object from a database. This version is more
convenient but will only compile if IFace::kDefaultIID is defined.
| db | [IN] - Database to instantiate from |
| uid | [IN] - UID of the boss. |
| inline |
Constructs an InterfacePtr from an object from a database.
| ref | [IN] - UIDRef of the boss object |
| iid | [IN] - IID of the desired interface from the boss. |
| inline |
Constructs an InterfacePtr from an object from a database.
This version is more convenient but will only compile if IFace::kDefaultIID is defined.
| ref | [IN] - UIDRef of the boss object |
| iid | [IN] - IID of the desired interface from the boss. |
| inline |
Detaches from the owned interface and transfers the ownership to the caller.
Note: The signature of this function makes it error-prone: if the caller doesn't take ownership of the interface (doesn't assign the result) the interface will be leaked.
| inline |
Accessor for the owned pointer.
| inline |
Implicit conversion operator. Allows implicit conversion between InterfacePtr<IFace> and IFace*.
| inline |
Boolean test operator (Null test).
| inline |
Indirection operator. If the pointer is nil, it will ASSERT in Debug builds and will
have unspecified behavior in the Release builds.
| inline |
Assigment operator. Increments the ref count of p by one.
This one enables InterfacePtr<const IFoo> = InterfacePtr<IFoo>
| p | [IN] - InterfacePtr to be copied. |
| inline |
Assigment operator. Increments the ref count of p by one.
This one enables copying of InterfacePtr of the same types.
| p | [IN] - InterfacePtr to be copied. |
| inline |
Releases the ownership for the current interface and attaches to the new one.
Note: the reference count of p will NOT be changed (AddRef is not called).
| p | [IN] - new interface pointer to take ownership of |