DoRunTimeC Class Reference
[Other classes]

#include <DoRunTime.h>

Inheritance diagram for DoRunTimeC:

DoRunTimeI DynI NamedRefI VObj DynI VObj

List of all members.

Others

Utility functions

enum  {
  MU_Ok = 0, MU_LibNotFound, MU_CallerNotFound, Mu_ModuleNotFound,
  MU_NoPerm, MU_NotOwned, MU_HasInstances, MU_DanglingOk,
  MU_DanglingReject
}
bool AddDOLib (DynObjLib *pdol)
const char * LoadLib (const char *lib_name)
DynILoadLib (const char *lib_name, DynI *pdi_init, int mod_flags)
int MayUnload (const char *lib_name)
bool UnloadDanglingLib (const char *lib_name)
DynObjLibGetMainLib ()
bool SetMalloc (MallocI *pmi)
void SetTextIo (TextIoI *ptio)
bool IsOk ()
bool PrepareShutdown ()
template<class T>
T * Create (doTypeWrapper< T >, const char *lib, const DynI *pdi_init=NULL)

Public Member Functions

void Dtor ()
virtual DynObj *docall Create (const char *lib, const char *type, int type_id, const DynI *pdi_init=NULL)
virtual DynI *docall LoadLib (const char *lib_name, DynI *pdi_init)
virtual bool docall UnloadLib (const char *lib_name)
virtual DynObjLibI *docall GetLib (const char *lib)
virtual const char *docall GetLoadError ()
virtual int docall GenerateTypeId ()
virtual bool docall RegisterModule (DoModuleC *pmi)
virtual bool docall UnRegisterModule (DoModuleC *pmi)
virtual DoModuleC *docall GetModuleByIndex (int ix)
virtual bool docall RegisterTypeVTable (void **vtbl, DynObjType *pdt)
virtual bool docall UnRegisterTypeVTable (void **vtbl)
virtual int docall MergeTypes (doModuleData *pmod_data)
virtual bool docall UnMergeTypes (doModuleData *pmod_data)
virtual bool docall IsValidType (DynObjType *pdt)
virtual DoModuleC *docall GetModuleByAddr (const void *paddr)
virtual DoModuleC *docall GetModuleForType (DoModuleC *pmod_caller, int type_id)
virtual bool docall SetObjectError (const void *pvo, const char *err_str, int err_code)
virtual bool docall ClearObjectError (const void *pvo)
virtual const char *docall GetObjectError (const void *pvo, int *perr_code)
virtual void docall OnObjectCreate (DynObj *pdo, DoModuleC *pmod)
virtual void docall OnObjectDestroy (DynObj *pdo, DoModuleC *pmod)
virtual void docall TempDisableCreate (bool disable)
virtual void docall SetModuleTempPermissions (DynObjLibI *plib, const void *base, int flags)
virtual void docall ResetModuleTempPermissions ()
virtual bool docall TrackDynObj (DynObj *pdo, NotifiableI *pni, bool begin_track, DynObjType *pdt)
virtual int docall AllocTypeItemTypeId ()
virtual void *docall MainAlloc (int size)
virtual bool docall MainFree (void *pmem)
Virtuals
Interface members

virtual DynObjType *docall doGetType (const DynI **pself=0) const
virtual void *docall doQueryI (const char *type)
virtual void docall doDestroy ()
virtual MallocI *docall GetMalloc () const
virtual TextIoI *docall GetTextIo () const
virtual int docall GetLastErrCode (int thid=-1)
virtual bool docall GetLastErrStr (DynStr &ds, int thid=-1)
virtual bool docall SetLastError (int err_code, const char *err_msg)
virtual int docall GetThreadId ()
virtual DynObjType *docall GetTypeOf (void **vtbl)
virtual DynObjType *docall FindTypeFromName (const char *type, const char *header=NULL)
virtual DynObjType *docall FindTypeFromId (int type_id)

Static Public Member Functions

static DoRunTimeCGetInstance (bool do_get=true)

Protected Member Functions

bool HasType (DynObjType *pdt)
bool AddType (DynObjType *pdt)
bool RemoveType (DynObjType *pdt)
DynObjTypeFindTypeFromNameAndId (const char *type, int type_id)
DynObjCreateGetType (const char *lib, const char *type, int type_id, const DynI *pdi_init, DynObjType **ppdt)
bool GetUserTypes (ExpArrP< DynObjType * > &arr, DynObjType **types, int length)
bool SortOutInstantiateTypes (ExpArrP< DynObjType * > &arr, DynObjType **types, int length, const char *instantiate_types)
int GetLibFlags (const char *paddr)
DynObjLibI *docall GetLibraryAt (const void *paddr)
bool LibHasType (DynObjLibI *plib, int type_id)
int GetCallerLib (OwnedDynObjLib *&polib, const char *pcaller_addr)
OwnedDynObjLib * GetOwnedLib (const char *lib_name)
int MayUnload (OwnedDynObjLib *polib, OwnedDynObjLib *polib_caller)
bool UnloadLib (const char *lib_name, OwnedDynObjLib *polib_caller)
DynISetLoadError (const char *error)
void FreeTrackers ()

Protected Attributes

MutexIm_pmut
MallocIm_pmalloc
TextIoIm_ptio
DynObjLibm_lib_last
ExpArrP< OwnedDynObjLib * > m_libs
ExpArrPOwn< DynObjLib * > m_libs_dangling
ExpArrP< DoModuleC * > m_modules
int m_type_id_nxt
int m_typeitem_typeid
int m_tmp_load_cnt
DynObjLibIm_tmp_load_lib
const char * m_tmp_load_base
int m_tmp_load_flags
CharBuf m_cb_load_err
HashTable< void **, DynObjType * > m_vptr2type
HashTable< int, DynObjType * > m_id2type
HashTable< const char
*, DynObjType * > 
m_name2type
ExpArrP< DynObjType * > m_types
ExpArrPOwn
< DelayedRegisterVTable * > 
m_delayed_vptrs
ExpArrP< DoBaseNode * > m_bases_unresolved
HashTable< DynObj
*, NotifiableI * > 
m_trackers
ExpArrP< DOError * > m_errors
HashTable< const void
*, DOError * > 
m_obj_errors
ExpArrPOwn< DOError * > m_oe_allocated
ExpArrP< DOError * > m_oe_avail
ExpArrP< char * > m_allocs
int m_tmp_disable

Friends

class OwnedDynObjLib


Detailed Description

The global instance of DoRunTime. Holds shared types and resources available tyo main program and the loaded libraries.

Member Function Documentation

static DoRunTimeC& DoRunTimeC::GetInstance ( bool  do_get = true  )  [static]

Get the one and only instance. If do_get==false, then ask to destroy the instance

virtual DynObjType* docall DoRunTimeC::doGetType ( const DynI **  pself = 0  )  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.

Parameters:
pself allows fetching the actual 'this' used inside doGetType (from a side base, this will be different to the 'this' of the caller).
Returns:
A DynObjType pointer

Reimplemented from DoRunTimeI.

virtual void* docall DoRunTimeC::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.

Returns:
A pointer to the found interface/internal object.

Reimplemented from DynI.

virtual MallocI* docall DoRunTimeC::GetMalloc (  )  const [inline, virtual]

Access shared functionality

Reimplemented from DoRunTimeI.

virtual DynObj* docall DoRunTimeC::Create ( const char *  lib,
const char *  type,
int  type_id,
const DynI pdi_init = NULL 
) [virtual]

Object creation

Parameters:
lib Library name or NULL if automatic search
type Type name (of created class)
type_id Type ID (of created class)
pdi_init Argument to constructor of new object
Returns:
Pointer to new DynObj

Reimplemented from DoRunTimeI.

virtual int docall DoRunTimeC::GetLastErrCode ( int  thid = -1  )  [virtual]

Global error handling - per thread

Reimplemented from DoRunTimeI.

virtual DynI* docall DoRunTimeC::LoadLib ( const char *  lib_name,
DynI pdi_init 
) [virtual]

Returns NULL on failure, otherwise object from library (or DORT itself)

Reimplemented from DoRunTimeI.

virtual bool docall DoRunTimeC::UnloadLib ( const char *  lib_name  )  [virtual]

Unloads a previously loaded library

virtual DynObjLibI* docall DoRunTimeC::GetLib ( const char *  lib  )  [virtual]

Returns an owned library (for temporary use)

Reimplemented from DoRunTimeI.

virtual DynObjType* docall DoRunTimeC::GetTypeOf ( void **  vtbl  )  [virtual]

Get type information from: VPTR / typename / type ID

Reimplemented from DoRunTimeI.

bool DoRunTimeC::AddDOLib ( DynObjLib pdol  ) 

Add/remove libraries. These functions take ownership of the libraries (until library is removed). The libraries are unloaded at application shutdown. Note: It is better to use LoadLib(name,pdi_init,mod_flags) since it sets up for possible shared ownership of the library.

const char* DoRunTimeC::LoadLib ( const char *  lib_name  ) 

Compatibility function to load libraries. Wrapper around these two: LoadLib( lib_name, pdi_init ) GetLoadError()

DynI* DoRunTimeC::LoadLib ( const char *  lib_name,
DynI pdi_init,
int  mod_flags 
)

Load a library with extra argument to set module load flags. (may allow loaded library to independently load libraries, or to override type instantiators)

bool DoRunTimeC::UnloadDanglingLib ( const char *  lib_name  ) 

Unload a library that is no longer owned by anyone (the only thing keeping it around is living instances, or that it rejects unloading. Returns true if lib was found and unloaded. Note: This is potentially dangerous if living instances _are_ actually around and will be used.

DynObjLib* DoRunTimeC::GetMainLib (  ) 

The main program is from one perspective a DynObjLib. This function returns the DynObjLib representing the main program in DoRunTime.

bool DoRunTimeC::SetMalloc ( MallocI pmi  ) 

Change the exposed memory allocator. Must do before memory allocation begins, otherwise this call fails

void DoRunTimeC::SetTextIo ( TextIoI ptio  )  [inline]

Set Text IoI currently used. This is where logging and printing goes to.

bool DoRunTimeC::IsOk (  ) 

Returns true if DoRunTime is alive and well and not shutting down

bool DoRunTimeC::PrepareShutdown (  ) 

This allows for unloading loaded libraries before global destructors are run

template<class T>
T* DoRunTimeC::Create ( doTypeWrapper< T >  ,
const char *  lib,
const DynI pdi_init = NULL 
) [inline]

Template wrapper of create above.

virtual bool docall DoRunTimeC::RegisterModule ( DoModuleC pmi  )  [virtual]

Module registration - internal use

virtual bool docall DoRunTimeC::RegisterTypeVTable ( void **  vtbl,
DynObjType pdt 
) [virtual]

Manage types based on VPTR (VTable pointer)

virtual bool docall DoRunTimeC::SetObjectError ( const void *  pvo,
const char *  err_str,
int  err_code 
) [virtual]

Handle per object errors

Reimplemented from DoRunTimeI.


The documentation for this class was generated from the following file:

Generated on Sun Feb 15 16:35:57 2009 for DynObj by  doxygen 1.5.6