RAVE
rave_object.c File Reference

Generic implementation of an object that is used within rave. More...

#include "rave_object.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include <stdio.h>

Classes

struct  _heapobject
 Heap structure when allocating rave objects. More...
 

Typedefs

typedef struct _heapobject heapobject
 Heap structure when allocating rave objects.
 

Functions

RaveCoreObjectRaveCoreObject_new (RaveCoreObjectType *type, const char *filename, int lineno)
 Creates a new instance of the provided type.
 
void RaveCoreObject_release (RaveCoreObject *obj, const char *filename, int lineno)
 Decrements the reference counter and if reference counts gets to 0, the destructor that was provided when creating the instance will be called.
 
RaveCoreObjectRaveCoreObject_copy (RaveCoreObject *src, const char *filename, int lineno)
 Increments the reference counter and returns a pointer to the provided object.
 
RaveCoreObjectRaveCoreObject_clone (RaveCoreObject *src, const char *filename, int lineno)
 Creates a clone of the provided object by using the types copyconstructor (if there is any).
 
int RaveCoreObject_getRefCount (RaveCoreObject *src)
 Returns the current reference count.
 
void RaveCoreObject_bind (RaveCoreObject *src, void *bindingData)
 Sets the binding data field, useful when for example associating this object with another object in order to manage objects from python or other languages.
 
void RaveCoreObject_unbind (RaveCoreObject *src, void *bindingData)
 Removes the binding from the rave object.
 
void * RaveCoreObject_getBindingData (RaveCoreObject *src)
 Returns the extra data.
 
int RaveCoreObject_isCloneable (RaveCoreObject *src)
 Returns if this object is possible to clone or not.
 
void RaveCoreObject_printCurrentObjectStatus (void)
 Print current status of object creation.
 
void RaveCoreObject_printStatistics (void)
 Prints the rave object statistics.
 
void RaveCoreObject_setTrackObjects (int track)
 Will track object creation and destruction.
 
int RaveCoreObject_getTrackObjects ()
 

Detailed Description

Generic implementation of an object that is used within rave.

All objects should use this as template for their structure.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-11-25

Typedef Documentation

◆ heapobject

typedef struct _heapobject heapobject

Heap structure when allocating rave objects.

Function Documentation

◆ RaveCoreObject_bind()

void RaveCoreObject_bind ( RaveCoreObject * src,
void * bindingData )

Sets the binding data field, useful when for example associating this object with another object in order to manage objects from python or other languages.

Do not use this function directly but use the macros for binding instead.

Parameters
[in]src- this object
[in]bindingData- the associated object (or similar)

◆ RaveCoreObject_clone()

RaveCoreObject * RaveCoreObject_clone ( RaveCoreObject * src,
const char * filename,
int lineno )

Creates a clone of the provided object by using the types copyconstructor (if there is any).

Parameters
[in]src- the object to be cloned
[in]filename- the filename that this operation was performed in
[in]lineno- the linenumber that this operation was performed in
Returns
a pointer to the cloned object

◆ RaveCoreObject_copy()

RaveCoreObject * RaveCoreObject_copy ( RaveCoreObject * src,
const char * filename,
int lineno )

Increments the reference counter and returns a pointer to the provided object.

Parameters
[in]src- the object to be copied
[in]filename- the filename that this operation was performed in
[in]lineno- the linenumber that this operation was performed in
Returns
a pointer to the copied object

◆ RaveCoreObject_getBindingData()

void * RaveCoreObject_getBindingData ( RaveCoreObject * src)

Returns the extra data.

Do not use this function directly but use the macros for binding objects instead.

Parameters
[in]src- this object
Returns
the binding data or NULL if none.

◆ RaveCoreObject_getRefCount()

int RaveCoreObject_getRefCount ( RaveCoreObject * src)

Returns the current reference count.

Parameters
[in]src- the the object that should be queried for reference count
Returns
the reference count.

◆ RaveCoreObject_getTrackObjects()

int RaveCoreObject_getTrackObjects ( )
Returns
if object creation / destruction is tracked.

◆ RaveCoreObject_isCloneable()

int RaveCoreObject_isCloneable ( RaveCoreObject * src)

Returns if this object is possible to clone or not.

Parameters
[in]src- the rave core object
Returns
1 if the object is possible to clone.

◆ RaveCoreObject_new()

RaveCoreObject * RaveCoreObject_new ( RaveCoreObjectType * type,
const char * filename,
int lineno )

Creates a new instance of the provided type.

Parameters
[in]type- the object type
[in]filename- the filename that this allocation was performed in
[in]lineno- the linenumber that this allocation was performed in
Returns
a new instance

◆ RaveCoreObject_printCurrentObjectStatus()

void RaveCoreObject_printCurrentObjectStatus ( void )

Print current status of object creation.

◆ RaveCoreObject_printStatistics()

void RaveCoreObject_printStatistics ( void )

Prints the rave object statistics.

◆ RaveCoreObject_release()

void RaveCoreObject_release ( RaveCoreObject * obj,
const char * filename,
int lineno )

Decrements the reference counter and if reference counts gets to 0, the destructor that was provided when creating the instance will be called.

Note, regardless on if and how the destructor has been implemented, the object will be freed.

Parameters
[in]obj- the object to release (including the object itself)
[in]filename- the filename that this operation was performed in
[in]lineno- the linenumber that this operation was performed in

◆ RaveCoreObject_setTrackObjects()

void RaveCoreObject_setTrackObjects ( int track)

Will track object creation and destruction.

Parameters
[in]track- if object creation / destruction should be tracked

◆ RaveCoreObject_unbind()

void RaveCoreObject_unbind ( RaveCoreObject * src,
void * bindingData )

Removes the binding from the rave object.

Do not use this function directly but use the macros for binding instead. If bindingData != the stored binding data nothing will happen.

Parameters
[in]src- this object
[in]bindingData- the binding to remove