Accessor functions for class wide datamembers/properties
- From: Mikoyan <miko2 pandora be>
- To: gtk-app-devel-list gnome org
- Subject: Accessor functions for class wide datamembers/properties
- Date: 12 Sep 2003 13:55:04 +0200
Hi all, I doubted where to post this question but I'll
try this list :-)
Imagine I have a DemoCarClass class structure containing
some datamembers like "tax_percentage". If want to create accessor
functions for this: how should they look like? I think
there are three possibilities:
1) like any function member of the class
E.g. demo_car_set_tax_percentage(DemoCar *self, guint tp);
The implementation of this function would call then something like:
DEMO_CAR_GET_CLASS(self)->tax_percentage = tp;
2) like any function member of the class, without the self ptr
E.g. demo_car_set_text_percentage(guint tp);
and would call something like this :
DEMO_CAR_CLASS(g_type_class_peek(DEMO_TYPE_CAR))->tax_percentage = tp;
3) something like demo_car_class_set_text_percentage
with or wihtout a DemoCarClass* ptr.
Personally I would go for 1) or 2). I think the user of a class should
NEVER touch the class structure, or should even need it.
What is the general coding convention? (I'm writing a GObject Class
Generator and I want to do it right).
Has anyone a word on this???
Greetingz,
Steven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]