Object


Modules

 Network
 Neuron
 Synapses

Data Structures

struct  _aspi_class
 Root object class structure. More...
struct  _aspi_object
 The root object structure. More...
typedef struct _aspi_class aspi_class_t
typedef struct _aspi_object aspi_object_t
void aspi_class_register (aspi_class_t *klass, aspi_class_t *parent, int size, void(*dtor)(aspi_object_t *object))
 Register a class.
aspi_class_taspi_object (void)
 Return the object class.
aspi_object_taspi_class_instantiate (aspi_class_t *klass)
 Alloc'er.
aspi_object_taspi_object_init (aspi_object_t *object)
 Root object initializer.
void aspi_object_dtor (aspi_object_t *object)
 Free an object (not to be called directly).
aspi_object_taspi_object_dup (aspi_object_t *object)
 Duplicate (in depth) an object (not to be called directly).
void aspi_object_free (aspi_object_t *object)
 Free an object.
aspi_object_taspi_object_copy (aspi_object_t *object)
 Copy an object.
void aspi_object_retain (aspi_object_t *object)
 Tells that the object is referenced, so it would be not cool to free it.
void aspi_object_release (aspi_object_t *object)
 Tells that the object isn't referenced anymore, and maybe free it.
int aspi_object_is_a (void *object, aspi_class_t *klass)
 Tell whether an object is a xxx or not.
int aspi_class_is_a (void *klass1, aspi_class_t *klass2)
 Tell whether a class is xxx or inherits it.
void aspi_object_check (void *object, aspi_class_t *klass)
 Check that an object is a xxx.
void aspi_class_check (void *klass1, aspi_class_t *klass2)
 Check that a class is a xxx.
#define ASPI_OBJECT(x)   (aspi_object_check (x, aspi_object ()), ((aspi_object_t *) x))
#define ASPI_CLASS(x)   (aspi_class_check (x, aspi_object ()), ((aspi_class_t * ) x))

Variables

struct _aspi_classparent
int size
void(* dtor )(struct _aspi_object *object)
struct _aspi_object *(* dup )(struct _aspi_object *object)
int reference_count

Detailed Description

This module defines the root object type, which is then herited by every other classes. In this object implementation, we have to define two structures for every class :

At first it can seem a bit complex, but actually you probably won't need to dive too deep into it to use this library: the only things to know is that:

If you want to add a feature in the library, it is a bit more complex, though. The best way to do this is to start from an existing file.


Define Documentation

#define ASPI_CLASS (  )     (aspi_class_check (x, aspi_object ()), ((aspi_class_t * ) x))

#define ASPI_OBJECT (  )     (aspi_object_check (x, aspi_object ()), ((aspi_object_t *) x))


Typedef Documentation

typedef struct _aspi_class aspi_class_t

typedef struct _aspi_object aspi_object_t


Function Documentation

void aspi_class_check ( void *  klass1,
aspi_class_t klass2 
)

Check that a class is a xxx.

If program is in debug mode, it will be aborted; else, a warning is displayed

References aspi_class_is_a(), and aspi_return_if_fail.

aspi_object_t * aspi_class_instantiate ( aspi_class_t klass  ) 

int aspi_class_is_a ( void *  klass1,
aspi_class_t klass2 
)

Tell whether a class is xxx or inherits it.

Returns:
1 if true, 0 if false

References aspi_return_value_if_fail, and _aspi_class::parent.

Referenced by aspi_class_check().

void aspi_class_register ( aspi_class_t klass,
aspi_class_t parent,
int  size,
void(*)(aspi_object_t *object)  dtor 
)

Register a class.

Parameters:
klass : pointer to the unitinialized klass
parent : pointer to the parent class, or NULL
Returns:
nothing
Note that this class should only be used by class which inherit object, no reason for a lib user to use it.

Also note that if parent class implement virtual functions, the child class must only set them if it wants to change them ; by default, the memory structure of the parent is copied

References aspi_return_if_fail, _aspi_class::dtor, _aspi_class::id, _aspi_class::parent, and _aspi_class::size.

Referenced by aspi_basic_synapses(), aspi_leaky(), aspi_network(), aspi_network_ml(), aspi_neuron(), aspi_object(), aspi_sparse_synapses(), and aspi_synapses().

aspi_class_t * aspi_object ( void   ) 

void aspi_object_check ( void *  object,
aspi_class_t klass 
)

Check that an object is a xxx.

If program is in debug mode, it will be aborted; else, a warning is displayed

References aspi_object_is_a(), and aspi_return_if_fail.

aspi_object_t * aspi_object_copy ( aspi_object_t object  ) 

Copy an object.

Virtual method

References aspi_return_value_if_fail, and _aspi_class::dup.

Referenced by aspi_network_dup().

void aspi_object_dtor ( aspi_object_t object  ) 

Free an object (not to be called directly).

References aspi_return_if_fail.

Referenced by aspi_network_dtor(), aspi_neuron_dtor(), aspi_object(), and aspi_synapses_dtor().

aspi_object_t * aspi_object_dup ( aspi_object_t object  ) 

Duplicate (in depth) an object (not to be called directly).

This core method should be called by classes that redefine this method.

It only copy all the datas of an object, so for deep-copy it is necessary to do a second passage.

References aspi_return_value_if_fail, _aspi_object::klass, _aspi_object::reference_count, and _aspi_class::size.

Referenced by aspi_leaky_dup(), aspi_network_dup(), and aspi_object().

void aspi_object_free ( aspi_object_t object  ) 

Free an object.

References aspi_return_if_fail, and _aspi_class::dtor.

Referenced by aspi_object_release().

aspi_object_t * aspi_object_init ( aspi_object_t object  ) 

Root object initializer.

This is the function that must be called by other classes, before their own init stuff

Parameters:
object : an alloc'ed object, or NULL to alloc it

References aspi_class_instantiate(), and aspi_object().

Referenced by aspi_network_init_full(), aspi_neuron_init(), and aspi_synapses_init().

int aspi_object_is_a ( void *  object,
aspi_class_t klass 
)

Tell whether an object is a xxx or not.

Returns:
1 if object is of this class or one that inherits it, 0 else

References aspi_return_value_if_fail, and _aspi_class::parent.

Referenced by aspi_network_get_freq_kurtosis(), aspi_network_get_freq_skewness(), and aspi_object_check().

void aspi_object_release ( aspi_object_t object  ) 

Tells that the object isn't referenced anymore, and maybe free it.

We only free the object if the reference count is zero

References aspi_object_free(), aspi_return_if_fail, and _aspi_object::reference_count.

Referenced by aspi_network_dtor().

void aspi_object_retain ( aspi_object_t object  ) 

Tells that the object is referenced, so it would be not cool to free it.

References aspi_return_if_fail.

Referenced by aspi_network_dup().


Variable Documentation

void(* dtor)(struct _aspi_object *object) [inherited]

struct _aspi_object*(* dup)(struct _aspi_object *object) [read, inherited]

struct _aspi_class* parent [read, inherited]

int reference_count [inherited]

int size [inherited]


Generated on Wed Aug 19 01:16:49 2009 for aspirenn by  doxygen 1.5.5