Solid Fluid System Solutions  
Home Software About Hardware Firmware
Folder Icon MemMgr
 
Our ANSI style memory management module.

Document Icon VCore (Library)
Document Icon Memory Manager
Document Icon Run-time Type
Current Document Icon Object Creation
Document Icon Constructor / Destructor
Document Icon Error Handling
Document Icon Verification
Document Icon Serialisation
Document Icon Synchronisation
Document Icon Thread Completion

Object Creation

For the purposes of run-time or dyamic object creation, the VObject base class implements a private static lookup, which contains pointers to _cdecl create handler functions.

Each executable or library module (.exe or .dll) generally specifies one create handler. The create handler is registered with VObject, normally when the module loads. Registration occurs in the lookup table which allows a mapping for the range of objects that a library could create, to a handler which is capable of actually performing their creation. The range of these objects is defined by the maximum and minimum value of run-time type within a given module.

The actual _cdecl create function is merely a switch statement that maps #defined object id's to a new operator for the associated class. Under run-time type a type management spreadsheet was described. In addition to the generation of type definition headers, it also generates these create handler functions, as C++ source files.

Using the object creation scheme is easy. VObject provides a function, CreateVObject(), which takes a run time type and an error handler. It returns a pointer to the newly created object with the requested type.

Internally VObject uses the lookup to determine which module create handler to use. It simply passes the original arguments on, to the chosen module and it's create handler.

Clearly, due to the simple mapping scheme used, a module could have more than one create handler. Typically this might be advantageous in the circumstance that an executable or dll file is acually composed of statically linked libraries. Each static library could have it's own create handler.

Not only is the create handler a useful capability to create new objects dynamically, but it is also an essential part of functions like Serialize().

Copyright © Solid Fluid 2007-2022
Last modified: SolFlu  Sat, 13 Jun 2009 00:38:32 GMT