/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/baseobject.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-12 19:04:18 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150712190418-yi9rfito5ovnf6dy
* Made the code more easy to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
#define S_OBJECT(k) (SObject *)k
91
91
#define S_OBJECT_CLASS(k) (SObjectClass *)k
92
92
 
93
 
struct SObjectClass {
 
93
struct
 
94
SObjectClass {
94
95
  MethodFunc initialize;
95
96
  MethodFunc deinitialize;
96
97
  FreeMethod free;
101
102
};
102
103
 
103
104
 
104
 
struct SObject {
 
105
struct
 
106
SObject {
105
107
  char * name; /*< The name of the class.*/
106
108
  SObjectClass * base_class; /*< holds the reference to the class. */
107
109
  SMap * callbacks; /*< This is what holds the callbacks. */
118
120
 * 
119
121
 * 
120
122
 */
121
 
void s_object_set_initialize_method (SObject * self, MethodFunc method);
 
123
void
 
124
s_object_set_initialize_method (SObject * self, MethodFunc method);
122
125
 
123
126
/**
124
127
 * This function is used to set the method to deinitialize an object.
125
128
 * 
126
129
 * set it to a method that deinitialize your object.
127
130
 */
128
 
void s_object_set_deinitialize_method (SObject * self, MethodFunc method);
 
131
void
 
132
s_object_set_deinitialize_method (SObject * self, MethodFunc method);
129
133
 
130
134
/**
131
135
 * This function is used to set the ref method.
132
136
 * 
133
137
 * @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
134
138
 */
135
 
void s_object_set_ref_method (SObject * self, MethodFuncInt method);
 
139
void
 
140
s_object_set_ref_method (SObject * self, MethodFuncInt method);
136
141
 
137
142
/**
138
143
 * This function is used to set the unref method.
139
144
 * 
140
145
 * @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
141
146
 */
142
 
void s_object_set_unref_method (SObject * self, MethodFuncInt method);
 
147
void
 
148
s_object_set_unref_method (SObject * self, MethodFuncInt method);
143
149
 
144
150
/**!
145
151
 * This function is used to set the get_refcount method.
146
152
 * 
147
153
 * @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
148
154
 */
149
 
void s_object_set_get_refcount_method (SObject * self,  MethodFuncInt method);
 
155
void
 
156
s_object_set_get_refcount_method (SObject * self,  MethodFuncInt method);
150
157
 
151
158
/**!
152
159
 * This function is used to set the to_string method.
153
160
 */
154
 
void s_object_set_to_string_method (SObject * self, ToStringFunc method);
 
161
void
 
162
s_object_set_to_string_method (SObject * self, ToStringFunc method);
155
163
 
156
164
/**
157
165
 *
158
166
 */
159
 
void s_object_set_free_method (SObject * self, MethodFunc method);
 
167
void
 
168
s_object_set_free_method (SObject * self, MethodFunc method);
160
169
 
161
170
 
162
171
/* concrete functions are defined in the C file.
175
184
 * This function initializes an instance of the SObject, it also sets
176
185
 * the methods to be used with the object and sets the reference count to one.
177
186
 */
178
 
void s_object_initialize (SObject * self, const char * name);
 
187
void
 
188
s_object_initialize (SObject * self, const char * name);
179
189
 
180
190
/** @brief
181
191
 * This function creates a new base object.
182
192
 * 
183
193
 * @return a new SObject
184
194
 */
185
 
SObject * s_object_new ();
 
195
SObject *
 
196
s_object_new ();
186
197
 
187
198
/**
188
199
 * This function desensitizes/frees an object even if it is still referenced.
189
200
 * This is usually a bad idea, use s_object_unref () instead.
190
201
 */
191
 
void s_object_free (SObject * self);
 
202
void
 
203
s_object_free (SObject * self);
192
204
 
193
205
/**
194
206
 * This function gets the class (which hold the object methods).
195
207
 */
196
 
SObjectClass * s_object_get_class (SObject * self);
 
208
SObjectClass *
 
209
s_object_get_class (SObject * self);
197
210
 
198
211
/**
199
212
 * This function sets the instance class of an object.
200
213
 */
201
 
void s_object_set_class (SObject * self, SObjectClass * klass);
 
214
void
 
215
s_object_set_class (SObject * self, SObjectClass * klass);
202
216
 
203
217
/**
204
218
 * This function is used to decrese the reference count of an object.
207
221
 * 
208
222
 * It returns the current (after change) reference count.
209
223
 */
210
 
int s_object_unref (SObject * self);
 
224
int
 
225
s_object_unref (SObject * self);
211
226
 
212
227
/**
213
228
 * This function is used to increase the reference count of an object.
214
229
 *
215
230
 * Returns the current (after change) reference count.
216
231
 */
217
 
int s_object_ref (SObject * self);
 
232
int
 
233
s_object_ref (SObject * self);
218
234
 
219
235
/**
220
236
 * This function returns the current reference count without changing it.
221
237
 */
222
 
int s_object_get_refcount (SObject * self);
 
238
int
 
239
s_object_get_refcount (SObject * self);
223
240
 
224
241
/**
225
242
 * This function returns a textual (string) that represents the object.
227
244
 *
228
245
 * Note: The string that is returned must be freed.
229
246
 */
230
 
char * s_object_to_string (SObject * self);
 
247
char *
 
248
s_object_to_string (SObject * self);
231
249
 
232
250
/**
233
251
 * @}