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_t * | aspi_object (void) |
Return the object class. | |
aspi_object_t * | aspi_class_instantiate (aspi_class_t *klass) |
Alloc'er. | |
aspi_object_t * | aspi_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_t * | aspi_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_t * | aspi_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_class * | parent |
int | size |
void(* | dtor )(struct _aspi_object *object) |
struct _aspi_object *(* | dup )(struct _aspi_object *object) |
int | reference_count |
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 ASPI_CLASS | ( | x | ) | (aspi_class_check (x, aspi_object ()), ((aspi_class_t * ) x)) |
#define ASPI_OBJECT | ( | x | ) | (aspi_object_check (x, aspi_object ()), ((aspi_object_t *) x)) |
Referenced by aspi_network_dup(), and aspi_network_ml_dup().
typedef struct _aspi_class aspi_class_t |
typedef struct _aspi_object aspi_object_t |
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 | ) |
Alloc'er.
Alloc memory to create an object of the class
References aspi_return_value_if_fail, and _aspi_class::size.
Referenced by aspi_basic_synapses_init(), aspi_leaky_init(), aspi_network_init_full(), aspi_network_ml_init_sparse(), aspi_neuron_init(), aspi_object_init(), aspi_sparse_synapses_init(), and aspi_synapses_init().
int aspi_class_is_a | ( | void * | klass1, | |
aspi_class_t * | klass2 | |||
) |
Tell whether a class is xxx or inherits it.
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.
klass | : pointer to the unitinialized klass | |
parent | : pointer to the parent class, or NULL |
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 | ) |
Return the object class.
= aspi_object_class
References aspi_class_register(), aspi_object_dtor(), aspi_object_dup(), _aspi_class::dup, and _aspi_class::id.
Referenced by aspi_network(), aspi_neuron(), aspi_object_init(), and aspi_synapses().
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
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.
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().
void(* dtor)(struct _aspi_object *object) [inherited] |
Referenced by aspi_class_register(), and aspi_object_free().
struct _aspi_object*(* dup)(struct _aspi_object *object) [read, inherited] |
Referenced by aspi_leaky(), aspi_object(), and aspi_object_copy().
struct _aspi_class* parent [read, inherited] |
Referenced by aspi_class_is_a(), aspi_class_register(), and aspi_object_is_a().
int reference_count [inherited] |
Referenced by aspi_object_dup(), and aspi_object_release().
int size [inherited] |
Referenced by aspi_class_instantiate(), aspi_class_register(), and aspi_object_dup().