Added a set method for serialization callback functions.
[libpopulation.git] / src / population.h
1 #ifndef POPULATION_H
2 #define POPULATION_H 1
3
4 #include <stdint.h>
5 #include <sys/types.h>
6
7 /*
8  * Callback function types
9  * (pi == population individual)
10  */
11 typedef int   (*pi_rate_f) (const void *);
12 typedef void *(*pi_copy_f) (const void *);
13 typedef void  (*pi_free_f) (void *);
14
15 typedef int   (*pi_serialize_f) (void *, char **, size_t *);
16 typedef void *(*pi_unserialize_f) (char *, size_t);
17
18 /*
19  * (Opaque) data types
20  */
21 struct population_s;
22 typedef struct population_s population_t;
23
24 /*
25  * Constructor and destructor
26  */
27 population_t *population_create (pi_rate_f rate, pi_copy_f copy, pi_free_f f);
28 void population_destroy (population_t *p);
29
30 /*
31  * Object configuration
32  */
33 int population_set_size (population_t *p, size_t population_size);
34 int population_set_serialization (population_t *p,
35     pi_serialize_f serialize, pi_unserialize_f unserialize);
36
37 /*
38  * Methods
39  */
40 /* iterations == 0  =>  infinite */
41 void *population_get_random (population_t *p);
42 void *population_get_fittest (population_t *p);
43
44 int population_insert (population_t *p, void *pi);
45
46 /* vim: set sw=2 sts=2 et : */
47 #endif /* POPULATION_H */