#include <DynObj.h>
Public Member Functions | |
Virtuals | |
Interface members | |
virtual DynObjType *docall | doGetType (const DynI **pself=NULL) const |
virtual void *docall | doQueryI (const char *type) |
virtual const char *docall | doGetError (int *perr_code=NULL) const |
virtual void docall docall | doClearError () |
Inlines | |
Inline convenience functions | |
DynObjType * | GetType () const |
bool | doIsOk () const |
const char * | GetTypeName () const |
int | GetTypeId () const |
int | GetObjectSize () const |
bool | IsA (int type_id) const |
bool | CanBeA (int type_id) const |
bool | IsA (const char *type) const |
void * | GetObj (int type_id, doCastAlgo algo=doCastFull) |
void * | GetObj (const char *type, doCastAlgo algo=doCastFull) |
void * | doGetObj (const char *type) |
This is the base type representing objects, interfaces and sub-objects created by a DynObj plugin. It knows its own type and can be queried for custom owned objects.
For compatibility with MSVC++, the member function calling convention 'docall' must be put between the return type and the function name: virtual int -->docall<-- MyFunc( int i );
virtual DynObjType* docall DynI::doGetType | ( | const DynI ** | pself = NULL |
) | const [virtual] |
Returns type of this object. Each type that wants to make itself known should override this method. DynI knows its own type so we get the type without any lookup. It is faster and works without registration.
pself | allows fetching the actual 'this' used inside doGetType (from a side base, this will be different to the 'this' of the caller). |
Reimplemented in DynData, NamedRefI, DynObjLibI, DoRunTimeI, DoModuleC, DoRunTimeC, DynObj, DynSharedI, DynObjLib, and DynStr.
virtual void* docall DynI::doQueryI | ( | const char * | type | ) | [virtual] |
'Smart cast' used to retrieve another interface or sub-object that this object implements/contains.
The default implementation of doQueryI traverses the registered main and side base classes for the object and returns any match found there. This is the same search as done when querying for types using type IDs.
A derived version can also check the argument type string and return a pointer to an owned object that is not a base class (custom types). The rule is that the returned object should have the same life span as this one, they are part of the same compound object.
When overriding this method, and not returning a custom object directly, one should call the immediate base class version. Then, after traversing the inheritance chain, the call will end up in the base version DynI::doGetObj. There, the call will be made to check for any registered base class types.
For versions with type safety, use do_cast or do_cast_str.
Reimplemented in DoRunTimeC.
virtual const char* docall DynI::doGetError | ( | int * | perr_code = NULL |
) | const [virtual] |
Returns current error string for object or NULL if no error. Object errors are used to handle errors that are not detected through return codes, i.e. exceptions. The default implementation uses DoRunTime for this. Errors are unique to the object but stored outside of it. No memory is used for this until an error is set.
perr_code | a location to store the error code, default is NULL |
virtual void docall docall DynI::doClearError | ( | ) | [virtual] |
This will clear the error state for the object if set
DynObjType* DynI::GetType | ( | ) | const [inline] |
Returns type structure for this object. Does a global lookup using object VPTR.
Reimplemented from VObj.
bool DynI::doIsOk | ( | ) | const [inline] |
Check if object exists and has no errors
Reimplemented from VObj.
const char* DynI::GetTypeName | ( | ) | const [inline] |
Returns name of type
Reimplemented from VObj.
bool DynI::IsA | ( | int | type_id | ) | const [inline] |
Test if object is of a certain type ID IsA returns true if the requested type can be returned without adjusting the 'this' pointer (must be main base class).
Reimplemented from VObj.
bool DynI::CanBeA | ( | int | type_id | ) | const [inline] |
Test if object 'can be' of a certain type ID CanBeA returns true if the requested type is available as any base class of the object (main base or side base).
Reimplemented from VObj.
bool DynI::IsA | ( | const char * | type | ) | const [inline] |
Same as IsA but using type string
Reimplemented from VObj.
void* DynI::GetObj | ( | int | type_id, | |
doCastAlgo | algo = doCastFull | |||
) | [inline] |
Raw cast, lookup internal type by type ID.
Reimplemented from VObj.
void* DynI::GetObj | ( | const char * | type, | |
doCastAlgo | algo = doCastFull | |||
) | [inline] |
Raw cast, lookup internal type by type string.
Reimplemented from VObj.