offbrand
A collection of generic, reference counted datastructures in C for C
 All Classes Files Functions Variables Typedefs Macros Groups
offbrand.h
Go to the documentation of this file.
1 
13 #ifndef OFFBRAND_LIB
14 #define OFFBRAND_LIB
15 
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <stdint.h>
19 #include <string.h>
20 #include <assert.h>
21 #include <time.h>
22 
24 #define OB_EQUAL_TO 0
25 
26 #define OB_GREATER_THAN 1
27 
28 #define OB_LESS_THAN -1
29 
31 #define OB_NOT_EQUAL 2
32 
34 #define OB_LEAST_TO_GREATEST -1
35 
36 #define OB_GREATEST_TO_LEAST 1
37 
43 typedef struct obj_struct * obj;
44 
49 typedef uint32_t ob_ref_count_t;
50 
52 typedef void (*ob_dealloc_fptr)(obj *);
53 
55 typedef size_t ob_hash_t;
56 
58 typedef ob_hash_t (*ob_hash_fptr)(const obj *);
59 
65 typedef int8_t (*ob_compare_fptr)(const obj *, const obj *);
66 
68 typedef void (*ob_display_fptr)(const obj *);
69 
70 
71 /* OFFBRAND STANDARD LIB */
72 
89 void ob_init_base(obj *instance, ob_dealloc_fptr dealloc_funct,
90  ob_hash_fptr hash_funct, ob_compare_fptr compare_funct,
91  ob_display_fptr display_funct, const char *classname);
92 
103 obj * ob_release(obj *instance);
104 
113 obj * ob_retain(obj *instance);
114 
121 uint32_t ob_reference_count(obj *instance);
122 
132 uint8_t ob_has_class(const obj *a, const char *classname);
133 
143 uint8_t ob_has_same_class(const obj *a, const obj *b);
144 
152 ob_hash_t ob_hash(const obj *to_hash);
153 
166 int8_t ob_compare(const obj *a, const obj *b);
167 
174 void ob_display(const obj *to_print);
175 
176 #endif
177