ooc 1.3
Object Oriented tollkit fo ANSI C

ooc.h File Reference

Object Oriented C - macros and definitions. More...

#include <stddef.h>
#include "port/anyc.h"
Include dependency graph for ooc.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  Class
 Class description table. More...
struct  Object
 ooc Object. More...
struct  InterfaceID
 Interface ID. More...

Defines

#define OOC_MANAGE   TRUE
 Container item management flag.
Class definitions.

These macros help define the class.

#define DeclareClass(pClass, pParent)
 Class declaration macro.
#define Virtuals(pClass, pParent)
 Class virtual functions declaration macro.
#define EndOfVirtuals
 End of virtual functions.
#define ClassMembers(pClass, pParent)
 Class members declaration macro.
#define EndOfClassMembers
 End of class members definition.
#define _ooc_decl_finalize(pClass)   static void pClass ## _finalize ( Class );
#define _ooc_decl_finalize_nopar(pClass)   static void pClass ## _finalize ();
#define _ooc_func_finalize(pClass)   (void (*)(ClassCommons)) pClass ## _finalize,
#define AllocateClass(pClass, pParent)
 Class allocation macro.
#define AllocateClassWithInterface(pClass, pParent)
 Class allocation macro for classes with interfaces.
#define chain_constructor(pClass, pSelf, pParam)
 Chain the parent constructor.
Managing Interfaces.

These macros help define and use the interfaces and mixins.

#define DeclareInterface(pInterface)
 Declare an interface.
#define DeclareMixinInterface(pMixin)
 Declare an interface for a mixin.
#define EndOfInterface
 Terminates the interface declaration.
#define Interface(pInterface)
 Place an interface into the class's virtual table.
#define MixinMembers(pMixin)
 Mixin data members declaration macro.
#define EndOfMixinMembers
 End of mixin members definition.
#define MixinData(pMixin)
 Place the mixin data fields into the carrier class's members.
#define AllocateInterface(pInterface)
 Allocates the interface descriptor table.
#define AllocateMixin(pMixin)
 Allocates the mixin descriptor table.
#define InterfaceRegister(pClass)
 Register for implemented interfaces of the class.
#define AddInterface(pClass, pInterface)
 Adds an interface to the class's interface register.
#define AddMixin(pClass, pMixin)
 Adds a mixin to the class's interface register.
#define ooc_get_interface(pObject, pInterface)
 Retrieves an interface of the Object.
#define ooc_get_interface_must_have(pObject, pInterface)
 Retrieves a mandatory interface of the Object.
#define ooc_get_mixin_data(pObject, pMixin)
 Retrieves the mixin data within the carrier object.

Functions

Memory handling.

ooc has it own memory handling that are based on their own stdc equivalents, except that they do not return a failure code, but throw an Exception instead.

void * ooc_malloc (size_t size)
 Memory allocation.
void * ooc_calloc (size_t num, size_t size)
 Memory allocation and clear.
void * ooc_realloc (void *ptr, size_t size)
 Memory reallocation.
void * ooc_memdup (const void *ptr, size_t size)
 Memory duplication.
char * ooc_strdup (const char *s)
 C string duplication.
void ooc_free (void *mem)
 Memory free.
void ooc_free_and_null (void **mem)
 Memory free and nulling pointer.
void * ooc_ptr_read_and_null (void **ptr_ptr)
 Pointer read and null.

Variables

struct ClassTable BaseClass
 Base Class.

Class initialization, finalization.

#define ooc_init_class(pClass)   _ooc_init_class( & pClass ## Class )
 Initializes a class.
#define ooc_finalize_class(pClass)   _ooc_finalize_class( & pClass ## Class )
 Finalizes a class.
#define ooc_isInitialized(pClass)   _ooc_isInitialized( & pClass ## Class )
 Checks if Class is initialized.
void _ooc_init_class (const Class class_ptr)
 Initializes a class by class table pointer.
void _ooc_finalize_class (const Class class_ptr)
 Finalizes a class by the class table pointer.
void ooc_finalize_all (void)
 Finalizes all classes.
int _ooc_isInitialized (const Class class_ptr)
 Checks if Class is initialized via a class table pointer.

Creating and deleting Objects.

#define ooc_new(pClass, pPar)   ((pClass) ooc_new_classptr( & pClass ## Class, pPar ))
 Creates a new object of a class.
#define ooc_use(mem, pClass, pPar)   ooc_use_classptr( mem, & pClass ## Class, pPar )
 Creates an Object of a Class using existing memory block.
Object ooc_new_classptr (const Class class_ptr, const void *par_ptr)
 Creates a new object of a class using class table pointer.
Object ooc_duplicate (const Object object)
 Duplicates an Object.
void ooc_delete (Object object)
 Deletes an Object.
void ooc_delete_and_null (Object *object_ptr)
 Deletes an Object via a pointer with nulling.
void ooc_use_classptr (void *mem, const Class class_ptr, const void *param)
 Creates an Object from a class table pointer using existing memory block.
Object ooc_copy (void *to, const Object from)
 Copies an Object to an another location.
void ooc_release (Object object)
 Destroys an Object, but does not free the memory.

Dynamic type checking.

Helpers to check the Object types in run-time.
#define ooc_isClassOf(pClass, pSuperClass)   _ooc_isClassOf( & pClass ## Class, & pSuperClass ## Class )
 Checks if a Class is inherited from an other Class.
#define ooc_isInstanceOf(pObj, pClass)   _ooc_isInstanceOf( (Object) pObj, & pClass ## Class )
 Checks if an Object is of a given type.
#define ooc_cast(pObj, pClass)   ( ooc_check_cast( pObj, & pClass ## Class ), (pClass) pObj )
 Run-time safe upcast of an Object.
#define ooc_class_has_parent(this)   (this->parent != &BaseClass)
 Checks if a Class has a parent class.
Class ooc_get_type (const Object object)
 Gets the type of the Object in run-time.
int _ooc_isClassOf (const Class this, const Class base)
 Checks if a Class is inherited from an other Class via class table pointers This is a convenient macro.
int _ooc_isInstanceOf (const Object object, const Class base)
 Checks if an Object is of a given type via class table pointer.
void ooc_check_cast (void *object, const Class target)
 Run-time safe check, if an Object can be upcast to an other type.

Detailed Description

Object Oriented C - macros and definitions.


Define Documentation

#define AddInterface (   pClass,
  pInterface 
)

Adds an interface to the class's interface register.

Parameters:
pClassThe name of the class that implements the interfaces.
pInterfaceThe name of the interface to be implemented for the class.
See also:
InterfaceRegister
#define AddMixin (   pClass,
  pMixin 
)

Adds a mixin to the class's interface register.

Parameters:
pClassThe name of the class that implements the mixin (the carrier class).
pMixinThe name of the mixin to be implemented for the class.
See also:
InterfaceRegister
#define AllocateClass (   pClass,
  pParent 
)

Class allocation macro.

This macro should be put int the implementation file of the class. Use:

 AllocateClass( MyClass, Base );
Parameters:
pClassThe name of the class.
pParentThe name of the parent class of the class. Must be Base if class does not have other parent.
#define AllocateClassWithInterface (   pClass,
  pParent 
)

Class allocation macro for classes with interfaces.

Allocates the class using the InterfaceRegister for the given class. The InterfaceRegister must be put right before this class allocator. For proper use see InterfaceRegister.

Parameters:
pClassThe name of the class.
pParentThe name of the parent class of the class. Must be Base if class does not have other parent.
See also:
InterfaceRegister, AllocateClass
#define AllocateInterface (   pInterface)

Allocates the interface descriptor table.

The interface descriptor table is used to uniquely identify an interface. This macro allocates this table and must be placed in a publicly available source file. In larger projects all interface descriptor table allocators can be put in a single file (e.g. in interfaces.c ).

Parameters:
pInterfaceThe name of the interface to be allocated.
See also:
InterfaceID
#define AllocateMixin (   pMixin)

Allocates the mixin descriptor table.

The mixin descriptor table is used to identify and describe a mixin. This macro allocates this table and must be placed in the mixin's implementation file.

Parameters:
pMixinThe name of the mixin to be allocated.
See also:
DeclareInterface(), MixinMembers()
#define chain_constructor (   pClass,
  pSelf,
  pParam 
)

Chain the parent constructor.

This macro calls the constructor of the parent class. Must be used soley in the constructor of the class, at the beginning of the constructor. Use:

 static void MyClass_constructor( MyClass self, void * params )
 {
        assert( ooc_isInitialized( MyClass ) );
 
        chain_constructor( MyClass, self, NULL );
 
        .... other construction code here
 }
Parameters:
pClassThe name of the actual class (not the parent!)
pSelfPointer to the Object being constructed.
pParamPointer to the construction parameters for the parent class's constructor. This pointer is passed to the constructor without any check.
Note:
In some rare cases you may neglect calling the parent constructor, e.g. when there is no parent class, or if you definitly know, that the parent class does not need construction, like in case of ListNode.
#define ClassMembers (   pClass,
  pParent 
)

Class members declaration macro.

This macro should be put int the implementation header of the class. Use:

 ClassMembers( MyClass, Base )
     int   my_data;
 EndOfClassMembers;
Parameters:
pClassThe name of the class.
pParentThe name of the parent class of the class. Must be Base if class does not have other parent.
See also:
EndOfClassMembers
#define DeclareClass (   pClass,
  pParent 
)

Class declaration macro.

This macro should be put int the publicly available header of the class. Use:

 DeclareClass( MyClass, Base );
Parameters:
pClassThe name of the class.
pParentThe name of the parent class of the class. Must be Base if class does not have other parent.
#define DeclareInterface (   pInterface)

Declare an interface.

This declaration should be placed in a publicly available header file. The declaration is followed by a semicolon separated list of function pointers. These function pointers represent the behavior of the interface. The first parameters of the function pointers should be an Object, since we do not know the exact type of the object right now, that implements the interface.

 DeclareInterface( Printable )
     void       (* print) ( Object );
     int        (* set_header) ( Object, const char * );
     ...
 EndOfInterface;
Parameters:
pInterfaceThe name of the interface.
See also:
EndOfInterface, DeclareMixinInterface()
#define DeclareMixinInterface (   pMixin)

Declare an interface for a mixin.

This is almost the same as the DeclareInterface() but is used to declare the interface methods of a mixin.

Parameters:
pMixinThe name of the mixin interface.
See also:
EndOfInterface, DeclareInterface()
#define EndOfClassMembers

End of class members definition.

This macro terminates the ClassMembers block.

See also:
ClassMembers()
#define EndOfInterface

Terminates the interface declaration.

See also:
DeclareInterface(), DeclareMixinInterface()
#define EndOfMixinMembers

End of mixin members definition.

This macro terminates the MixinMembers block.

See also:
MixinMembers()
#define EndOfVirtuals

End of virtual functions.

This macro terminates the Virtuals block.

See also:
Virtuals()
#define Interface (   pInterface)

Place an interface into the class's virtual table.

This macro places the interface methods into the class's virtual table. This marks that he interface methods can be accessed via the virtual table, and are inherited as any normal virtual function. Use:

 Virtuals( MyClass, Base )
        int   (* my_method) ( MyClass self, int param );
            ...
        Interface( HasProperties );
        Interface( Printable );
 EndOfVirtuals;
Parameters:
pInterfaceThe name of the interface to be implemented by the class.
#define InterfaceRegister (   pClass)

Register for implemented interfaces of the class.

In the class implementation code you must define, which interfaces are implemented by the class. These interfaces must be listed in the InterfaceRegister right before the AllocateClassWithInterface macro. Typical use (in myclass.c):

 InterfaceRegister( MyClass )
 {
        AddInterface( MyClass, HasProperties ),
        AddInterface( MyClass, Printable ),
        AddMixin( MyClass, Flavour )
 };

 AllocateClassWithInterface( MyClass, Base );
Parameters:
pClassThe name of the class that implements the listed interfaces.
Note:
Listen to the different syntax! Internally this is a table of structs, so you must end it with a semicolon, and use comma as the internal list separator. You must not put a comma after the last item in the list!
See also:
AddInterface, AllocateClassWithInterface
Warning:
Using AllocateClass instead of AllocateClassWithInterface will not put the registered interfaces into the class table, thus none of the interfaces could be used! Always use AllocateClassWithInterface after an InterfaceRegister!
#define MixinData (   pMixin)

Place the mixin data fields into the carrier class's members.

This macro places the mixin data fields (in case of Mixins) into the object struct. Use:

 ClassMembers( IceCream, Tonic )
        int         scoop;
        MixinData(  Flavour );
 EndOfClassMembers;
Parameters:
pMixinThe name of the mixin (must be idenctical with the name of the corresponding interface) to be implemented by the carrier class.
Note:
This macro puts the mixin data into the Object struct. The enclosing class can access the members of the mixed in class. :-(
Warning:
Important! The MixinData() macros must always be the last elements of an Object! /n Never put any data member behind or among the MixinData() definitions!
#define MixinMembers (   pMixin)

Mixin data members declaration macro.

This macro should be put int the implementation header of the mixin. Use:

 MixinMembers( MyMixin )
     int   my_data;
 EndOfMixinMembers;
Parameters:
pMixinThe name of the mixin (must be identical with the corresponding interface name!).
See also:
EndOfClassMembers, DeclareInterface
#define ooc_cast (   pObj,
  pClass 
)    ( ooc_check_cast( pObj, & pClass ## Class ), (pClass) pObj )

Run-time safe upcast of an Object.

Safely upcasts the Object to the specified type. Throws an Exception if not possible. This is a macro.

Parameters:
pObjThe Object to be cast.
pClassThe desired type (Class name).
Returns:
The Objcet as a new type.
See also:
ooc_check_cast()
#define ooc_class_has_parent (   this)    (this->parent != &BaseClass)

Checks if a Class has a parent class.

This is a convenient macro.

Parameters:
thisThe Class that should be checked.
Returns:
TRUE or FALSE. Returns TRUE if the Class has a parent class. Does not throw an Exception.
#define ooc_finalize_class (   pClass)    _ooc_finalize_class( & pClass ## Class )

Finalizes a class.

Finalizes a class using the class name. This is a convenient macro.

Parameters:
pClassTha name of the class.
See also:
_ooc_finalize_class().
#define ooc_get_interface (   pObject,
  pInterface 
)

Retrieves an interface of the Object.

Returns the interface pointer for the given Object. Typical use:

 void
 print_if_printable( Object object )
 {
        Printable printable = get_interface( object, Printable );

        if( printable )
            printable->print( object );
 }
Parameters:
pObjectThe Object of which's interface we are interested in.
pInterfaceThe name of the interface to be retrieved.
Returns:
The interface (pointer to the interface methods table), or NULL if this interface is not implemented for the class.
See also:
ooc_get_interface_must_have, DeclareInterface
#define ooc_get_interface_must_have (   pObject,
  pInterface 
)

Retrieves a mandatory interface of the Object.

Returns the interface pointer for the given Object. The Interface must have been implemented for the given Object, otherwise err_interface_not_implemented Exception is thrown.

Parameters:
pObjectThe Object of which's interface we are interested in.
pInterfaceThe name of the interface to be retrieved.
Returns:
The interface (pointer to the interface methods table), never returns NULL. Throws an Exception with error code of err_interface_not_implemented if the interface is not implemented for this class.
See also:
ooc_get_interface
#define ooc_get_mixin_data (   pObject,
  pMixin 
)

Retrieves the mixin data within the carrier object.

Returns the pointer to the Mixin data for the given carrier Object. The Mixin must have been implemented for the given Object, otherwise err_interface_not_implemented Exception is thrown.

Parameters:
pObjectThe Object of which's interface we are interested in. (The carrier Object.)
pMixinThe name of the mixin to be retrieved.
Returns:
Pointer to the mixin's data fields in the carrier Object. Never returns NULL. Throws an Exception with error code of err_interface_not_implemented if the mixin is not implemented for this class.
Note:
This can be used only within a mixin implementation!
This macro must be used for each mixin method to retrieve the mixin data fields.
See also:
ooc_get_interface()
#define ooc_init_class (   pClass)    _ooc_init_class( & pClass ## Class )

Initializes a class.

Initializes a class using the class name. This is a convenient macro.

Parameters:
pClassTha name of the class.
See also:
_ooc_init_class().
Warning:
This method is not thread safe!
#define ooc_isClassOf (   pClass,
  pSuperClass 
)    _ooc_isClassOf( & pClass ## Class, & pSuperClass ## Class )

Checks if a Class is inherited from an other Class.

This is a convenient macro.

Parameters:
pClassThe Class that should be checked.
pSuperClassThe required type
Returns:
TRUE or FALSE. Returns TRUE if the Class is inherited from the given pSuperClass. Does not throw an Exception.
See also:
_ooc_isClassOf()
#define ooc_isInitialized (   pClass)    _ooc_isInitialized( & pClass ## Class )

Checks if Class is initialized.

This is a convenient macro.

Parameters:
pClassThe Class that should be checked.
Returns:
TRUE or FALSE. Does not throw an Exception.
See also:
_ooc_isInitialized()
#define ooc_isInstanceOf (   pObj,
  pClass 
)    _ooc_isInstanceOf( (Object) pObj, & pClass ## Class )

Checks if an Object is of a given type.

This is a convenient macro. Returns TRUE if the Object is of the given Class or any of its parent classes.

Parameters:
pObjThe Object to be checked.
pClassThe Class that should be matched.
Returns:
TRUE or FALSE. Does not throw an Exception.
See also:
_ooc_isInstanceOf()
#define OOC_MANAGE   TRUE

Container item management flag.

Indicates that the contents of a container must be managed by the container itself.

See also:
vector_new_type(), list_new_type()
#define ooc_new (   pClass,
  pPar 
)    ((pClass) ooc_new_classptr( & pClass ## Class, pPar ))

Creates a new object of a class.

Creates a new object of a class with the given construction parameters.

Parameters:
pClassThe name of the class.
pParPointer to the construction parameters. This pointer is passed to the constructor without any check.
Returns:
The newly created Object.
Note:
ooc_new may throw an Exception! This is a convenient macro for ooc_new_classptr().
See also:
ooc_new_classptr()
#define ooc_use (   mem,
  pClass,
  pPar 
)    ooc_use_classptr( mem, & pClass ## Class, pPar )

Creates an Object of a Class using existing memory block.

Creates a new object of a class with the given construction parameters using the memory block provided. This method does not call the memory allocator for the Object

Parameters:
memThe memory block to be used for the Object
pClassThe name of the class.
pParPointer to the construction parameters. This pointer is passed to the constructor without any check.
Returns:
Nothing.
Note:
ooc_use may throw an Exception! This is a convenient macro for ooc_use_classptr().
See also:
ooc_use_classptr()
Warning:
The caller must ensure that the memory block pointed by mem is large enough to hold the Object!
#define Virtuals (   pClass,
  pParent 
)

Class virtual functions declaration macro.

This macro should be put int the publicly available header of the class. Use:

 Virtuals( MyClass, Base )
     int   (* my_method) ( MyClass self, int param );
 EndOfVirtuals;
Parameters:
pClassThe name of the class.
pParentThe name of the parent class of the class. Must be Base if class does not have other parent.
See also:
EndOfVirtuals

Function Documentation

void _ooc_finalize_class ( const Class  class_ptr)

Finalizes a class by the class table pointer.

Finalizes a class using the class table pointer.

Parameters:
class_ptrPointer to the class description table.
See also:
ooc_finalize_class() for more convenient use.
void _ooc_init_class ( const Class  class_ptr)

Initializes a class by class table pointer.

Initializes the class pointed by the parameter.

Parameters:
class_ptrPointer to the class description table.
See also:
ooc_init_class() for more convenient use.
Warning:
This method is not thread safe!
int _ooc_isClassOf ( const Class  this,
const Class  base 
)

Checks if a Class is inherited from an other Class via class table pointers This is a convenient macro.

Parameters:
thisThe Class that should be checked.
baseThe required type
Returns:
TRUE or FALSE. Returns TRUE if the Class is inherited from the given pSuperClass. Does not throw an Exception.
See also:
ooc_isClassOf()
int _ooc_isInitialized ( const Class  class_ptr)

Checks if Class is initialized via a class table pointer.

This is a convenient macro.

Parameters:
class_ptrThe class table pointer to the Class that should be checked.
Returns:
TRUE or FALSE.
See also:
ooc_isInitialized() for more convenient use.
int _ooc_isInstanceOf ( const Object  object,
const Class  base 
)

Checks if an Object is of a given type via class table pointer.

Returns TRUE if the Object is of the given Class or any of its parent classes.

Parameters:
objectThe Object to be checked.
baseThe Class that should be matched.
Returns:
TRUE or FALSE. Does not throw an Exception.
See also:
ooc_isInstanceOf() for more convenient use.
void* ooc_calloc ( size_t  num,
size_t  size 
)

Memory allocation and clear.

Allocates memory like calloc(), but throws an Exception on error

void ooc_check_cast ( void *  object,
const Class  target 
)

Run-time safe check, if an Object can be upcast to an other type.

Safely chaecks if the Object could be upcast to the specified type. Throws an Exception if not possible.

Parameters:
objectThe Object to be cast.
targetThe desired type (Class name).
Returns:
Just returns, or throws an Exception if casting is not possible.
See also:
ooc_cast()
Object ooc_copy ( void *  to,
const Object  from 
)

Copies an Object to an another location.

Calling the copy constructor of the Object, copies the content into an other location.

Parameters:
toThe destination location of the copied object. The caller must ensure, that the destination location is large enough to hold the newly created Object!
fromThe original Object to be copied.
Returns:
The newly created Object.
Note:
May throw an Exception.
Warning:
If in a multi-threaded application your Object needs to be in a consistent state while copying, you must lock it yourself. ooc_copy() does not do any locking.
void ooc_delete ( Object  object)

Deletes an Object.

Deletes the Object using its destructor, then deallocating the memory.

Parameters:
objectThe Object to be deleted. Can be NULL.
void ooc_delete_and_null ( Object *  object_ptr)

Deletes an Object via a pointer with nulling.

Deletes the Object using its destructor, then deallocating the memory. Thread safely and reentrat safely NULLs the pointer.

Parameters:
object_ptrPointer to the Object to be deleted. Can be NULL and the object pointer can be NULL as well.
Note:
Use this version in class destructors! This is important to ensure the reentrancy for destructors.
Object ooc_duplicate ( const Object  object)

Duplicates an Object.

Calling the copy constructor of the Object, creates a duplicate of it.

Parameters:
objectThe original Object.
Returns:
The newly created Object.
Returns NULL if the parameter is NULL. (Useful in copy constructors, you do not have to check if the member Object to be copied exists or not.)
Note:
May throw an Exception.
Warning:
In a multi-threaded application your Object needs to be in a consistent state while copying, you must lock it yourself. ooc_duplicate() does not do any locking.
void ooc_free ( void *  mem)

Memory free.

Frees memory allocated by ooc_malloc(), ooc_calloc() or ooc_realloc()

void ooc_free_and_null ( void **  mem)

Memory free and nulling pointer.

Frees memory via a pointer, and NULL the pointer thread safely

Class ooc_get_type ( const Object  object)

Gets the type of the Object in run-time.

Parameters:
objectThe Object.
Returns:
The Object's type: a pointer to the class table.
Note:
Throws an Exception if object is not a valid Object.
void* ooc_malloc ( size_t  size)

Memory allocation.

Allocates memory like malloc(), but throws an Exception on error

void* ooc_memdup ( const void *  ptr,
size_t  size 
)

Memory duplication.

Duplicates a memory block with a new alloc, throws an Exception on error

Object ooc_new_classptr ( const Class  class_ptr,
const void *  par_ptr 
)

Creates a new object of a class using class table pointer.

Creates a new object of a class with the given class table pointer and construction parameters.

Parameters:
class_ptrThe pointer to the class description table.
par_ptrPointer to the construction parameters. This pointer is passed to the constructor without any check.
Returns:
The newly created Object.
Note:
ooc_new may throw an Exception!
See also:
ooc_new_classptr() for more convenient use.
void* ooc_ptr_read_and_null ( void **  ptr_ptr)

Pointer read and null.

Reads a pointer via a pointer, and nulls thread safely. Atomic operation in case of GNUC and MSVC on x86 platforms. For other compilers this is equuivalent to the following code:

 void * tmp = * ptr_ptr;
 *ptr_ptr = NULL;
 return tmp;

wich is not thread safe but re-entrant safe.

void* ooc_realloc ( void *  ptr,
size_t  size 
)

Memory reallocation.

Reallocates memory like realloc(), but throws an Exception on error

void ooc_release ( Object  object)

Destroys an Object, but does not free the memory.

Calls the Object's destructor, but does not free the memory block used by the Object.

Parameters:
objectThe Object to be released.
See also:
ooc_use()
char* ooc_strdup ( const char *  s)

C string duplication.

Duplicates a C string with a new alloc, throws an Exception on error

void ooc_use_classptr ( void *  mem,
const Class  class_ptr,
const void *  param 
)

Creates an Object from a class table pointer using existing memory block.

Creates a new object of a class with the given construction parameters using the memory block provided. This method does not call the memory allocator for the Object

Parameters:
memThe memory block to be used for the Object
class_ptrThe class table pointer.
paramPointer to the construction parameters. This pointer is passed to the constructor without any check.
Returns:
Nothing.
Note:
ooc_use_classptr may throw an Exception!
See also:
ooc_use() for more convenient use.
Warning:
The caller must ensure that the memory block pointed by mem is large enough to hold the Object!

Variable Documentation

Base Class.

Used for root Class in ooc. It must be a superclass for all classes.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines