GTS Library Reference Manual |
---|
#include <gts.h> #define GTS_CLASS_NAME_LENGTH #define GTS_OBJECT_CLASS (klass) #define GTS_OBJECT (obj) #define GTS_IS_OBJECT (obj) #define GTS_OBJECT_CLASS_CAST (objklass, type, klass) #define GTS_OBJECT_CAST (obj, type, klass) #define GTS_OBJECT_FLAGS (obj) #define GTS_OBJECT_SET_FLAGS (obj,flag) #define GTS_OBJECT_UNSET_FLAGS (obj,flag) #define GTS_OBJECT_DESTROYED (obj) GtsObjectClass; GtsObject; GtsObjectClassInfo;void (*GtsObjectClassInitFunc) (GtsObjectClass *objclass);void (*GtsObjectInitFunc) (GtsObject *obj);void (*GtsArgSetFunc) (GtsObject *obj);void (*GtsArgGetFunc) (GtsObject *obj); enum GtsObjectFlags; GtsColor; GtsObjectClass* gts_object_class (void);gpointer gts_object_class_new (GtsObjectClass *parent_class, GtsObjectClassInfo *info);gpointer gts_object_class_check_cast (gpointer klass,gpointer from);gpointer gts_object_class_is_from_class (gpointer klass,gpointer from); GtsObjectClass* gts_object_class_from_name (constgchar *name); GtsObject* gts_object_new (GtsObjectClass *klass);void gts_object_init (GtsObject *object, GtsObjectClass *klass); GtsObject* gts_object_clone (GtsObject *object);void gts_object_attributes (GtsObject *object, GtsObject *from);gpointer gts_object_check_cast (gpointer object,gpointer klass);gpointer gts_object_is_from_class (gpointer object,gpointer klass);void gts_object_reset_reserved (GtsObject *object);void gts_object_destroy (GtsObject *object);void gts_finalize (void);
All GTS objects are derived from this base class. Objects of any class can be constructed using the gts_object_new()
function and destroyed using the gts_object_destroy()
function. Default virtual methods include read()
write()
#define GTS_IS_OBJECT(obj)
Evaluates to TRUE if obj
is a GtsObject, FALSE otherwise.
obj : | a pointer to test. |
#define GTS_OBJECT_CLASS_CAST(objklass, type, klass)
This macro is used to define casting macros for object classes. You should need it only when writing new object class functions.
objklass : | |
type : | The class type to cast |
klass : | the class to cast |
#define GTS_OBJECT_CAST(obj, type, klass)
This macro is used to define casting macros for object. You should need it only when writing new object functions.
obj : | a GtsObject. |
type : | the object type to cast |
klass : | the object class to cast |
#define GTS_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (GTS_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
obj : | |
flag : |
|
#define GTS_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (GTS_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
obj : | |
flag : |
|
#define GTS_OBJECT_DESTROYED(obj) ((GTS_OBJECT_FLAGS (obj) & GTS_DESTROYED) != 0)
obj : |
|
typedef struct { GtsObjectClassInfo info; GtsObjectClass * parent_class; void (* clone) (GtsObject *, GtsObject *); void (* destroy) (GtsObject *); void (* read) (GtsObject **, GtsFile *); void (* write) (GtsObject *, FILE *); GtsColor (* color) (GtsObject *); void (* attributes) (GtsObject *, GtsObject *); } GtsObjectClass;
The base object class structure. All the virtual functions clone
, destroy
, read
and write
can be overloaded. The default read
and write
methods are undefined. The default clone
method just copies the object structure. The default destroy
method frees the memory allocated for a given object structure.
typedef struct { GtsObjectClass * klass; gpointer reserved; guint32 flags; } GtsObject;
The base object structure.
GtsObjectClass *klass ; | The object class. |
reserved ; | Used internally by the library. |
flags ; | Used internally. |
typedef struct { gchar name[GTS_CLASS_NAME_LENGTH]; guint object_size; guint class_size; GtsObjectClassInitFunc class_init_func; GtsObjectInitFunc object_init_func; GtsArgSetFunc arg_set_func; GtsArgGetFunc arg_get_func; } GtsObjectClassInfo;
Informations about a GtsObjectClass, including name, size of the object structure to be allocated when constructing the object, size of the object class structure to be allocated when instanciating the object class, class initialization function, object initialization function.
void (*GtsObjectClassInitFunc) (GtsObjectClass *objclass);
A function to call to initialize an object class.
objclass : | a GtsObjectClass to be initialized. |
void (*GtsObjectInitFunc) (GtsObject *obj);
A function to call to initialize an object.
obj : | a GtsObject. |
typedef enum { GTS_DESTROYED = 1 << 0, GTS_USER_FLAG = 1 /* user flags start from here */ } GtsObjectFlags;
gpointer gts_object_class_new (GtsObjectClass *parent_class, GtsObjectClassInfo *info);
parent_class : | |
info : | a GtsObjectClassInfo, description of the new class to create. |
Returns : | a new GtsObjectClass derived from |
gpointer gts_object_class_check_cast (gpointer klass,gpointer from);
klass : | |
from : | |
Returns : | |
gpointer gts_object_class_is_from_class (gpointer klass,gpointer from);
klass : | |
from : | |
Returns : | |
GtsObjectClass* gts_object_class_from_name (constgchar *name);
name : | the name of a GtsObjectClass. |
Returns : | the GtsObjectClass with name |
GtsObject* gts_object_new (GtsObjectClass *klass);
klass : | |
Returns : | a new initialized object of class |
void gts_object_init (GtsObject *object, GtsObjectClass *klass);
Calls the init method of klass
with object
as argument. This is done
recursively in the correct order (from the base class to the top). You
should rarely need this function as it is called automatically by the
constructor for each class.
object : | a GtsObject. |
klass : |
GtsObject* gts_object_clone (GtsObject *object);
Calls the clone method of object
. The call to this function will fail
if no clone method exists for the given object.
object : | a GtsObject. |
Returns : | a new object clone of |
void gts_object_attributes (GtsObject *object, GtsObject *from);
Calls the attributes()
object
using from
as source.
object : | a GtsObject. |
from : | a GtsObject. |
gpointer gts_object_check_cast (gpointer object,gpointer klass);
object : | a GtsObject. |
klass : | |
Returns : | |
gpointer gts_object_is_from_class (gpointer object,gpointer klass);
object : | a GtsObject. |
klass : | |
Returns : | |
void gts_object_reset_reserved (GtsObject *object);
Reset the reserved field of object
.
object : | a GtsObject. |
void gts_object_destroy (GtsObject *object);
Calls the destroy method of object
, freeing all memory allocated for it.
object : | a GtsObject. |
<<< Geometrical Object Hierarchy | Container classes >>> |