Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Class
[Object: Dynamic Object Class Framework]


Detailed Description

This file defines a class messaging system reminiscent of traditional OO-style setter and getter interfaces to object properties. A C-language object can declare a collection of setters and getters on itself that can then be used to perform run-time (as opposed to compile-time) bindings to the object.

To put it differently, a QOF class is a set of parameter getters and setters that are associated with an object type. Given a pointer to some thing, the setters and getters can be used to get and set values out of that thing. Note that the pointer to "some thing" need not be a pointer to a QOF Entity or Instance (although QOF classes are more interesting when used with Entities/Instances). What "some thing" is defined entirely by the programmer declaring a new QOF Class.

Because a QOF Class associates getters and setters with a type, one can then ask, at run time, what paramters are associated with a given type, even if those paramters were not known at compile time. Thus, a QOF Class is sort-of like a DynAny implementation. QOF classes can be used to provide "object introspection", i.e. asking object to describe itself.

The QOF Query subsystem depends on QOF classes having been declared; the Query uses the getters to get values associated with particular instances.


Files

file  qofclass.h
 API for registering paramters on objects.


Data Structures

struct  _QofParam

Defines

#define QOF_TYPE_STRING   "string"
#define QOF_TYPE_DATE   "date"
#define QOF_TYPE_NUMERIC   "numeric"
#define QOF_TYPE_DEBCRED   "debcred"
#define QOF_TYPE_GUID   "guid"
#define QOF_TYPE_INT32   "gint32"
#define QOF_TYPE_INT64   "gint64"
#define QOF_TYPE_DOUBLE   "double"
#define QOF_TYPE_BOOLEAN   "boolean"
#define QOF_TYPE_KVP   "kvp"
#define QOF_TYPE_CHAR   "character"

Typedefs

typedef const char * QofType
typedef _QofParam QofParam
typedef gpointer(* QofAccessFunc )(gpointer object, const QofParam *param)
typedef void(* QofSetterFunc )(gpointer, gpointer)
typedef int(* QofSortFunc )(gpointer, gpointer)

Functions

void qof_class_register (QofIdTypeConst obj_name, QofSortFunc default_sort_fcn, const QofParam *params)
gboolean qof_class_is_registered (QofIdTypeConst obj_name)
QofType qof_class_get_parameter_type (QofIdTypeConst obj_name, const char *param_name)
const QofParamqof_class_get_parameter (QofIdTypeConst obj_name, const char *parameter)
QofAccessFunc qof_class_get_parameter_getter (QofIdTypeConst obj_name, const char *parameter)
QofSetterFunc qof_class_get_parameter_setter (QofIdTypeConst obj_name, const char *parameter)


Define Documentation

#define QOF_TYPE_STRING   "string"
 

Core types of objects that can be used in parameters. Note that QofIdTypes may also be used.


Typedef Documentation

typedef gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
 

The QofAccessFunc defines an arbitrary function pointer for access functions. This is needed because C doesn't have templates, so we just cast a lot. Real functions must be of the form:

param_type getter_func (object_type *self); or param_type getter_func (object_type *self, QofParam *param);

The additional argument 'param' allows generic getter functions to be implemented, because this argument provides for a way to identify the expected getter_func return type at runtime. It also provides a place for the user to hang additional user-defined data.

typedef void(* QofSetterFunc)(gpointer, gpointer)
 

The QofSetterFunc defines an function pointer for parameter setters. Real functions must be of the form:

void setter_func (object_type *self, param_type *param);

typedef int(* QofSortFunc)(gpointer, gpointer)
 

This function is the default sort function for a particular object type

typedef const char* QofType
 

Type of Paramters (String, Date, Numeric, GUID, etc.)


Function Documentation

const QofParam* qof_class_get_parameter QofIdTypeConst  obj_name,
const char *  parameter
 

Return the registered Parameter Definition for the requested parameter

QofAccessFunc qof_class_get_parameter_getter QofIdTypeConst  obj_name,
const char *  parameter
 

Return the object's parameter getter function

QofSetterFunc qof_class_get_parameter_setter QofIdTypeConst  obj_name,
const char *  parameter
 

Return the object's parameter setter function

QofType qof_class_get_parameter_type QofIdTypeConst  obj_name,
const char *  param_name
 

Return the core datatype of the specified object's parameter

gboolean qof_class_is_registered QofIdTypeConst  obj_name  ) 
 

Return true if the the indicated type is registered, else return FALSE.

void qof_class_register QofIdTypeConst  obj_name,
QofSortFunc  default_sort_fcn,
const QofParam params
 

This function registers a new object class with the Qof subsystem. In particular, it registers the set of setters and getters for controlling the object. The getters are typically used by the query subsystem to query type specific data. Note that there is no particular reqquirement for there to be a setter for every getter or even v.v. nor is there any requeirement for these to map 'cleanly' or orthogonaly to the actual object design.

The "params" argument must be a NULL-terminated array of QofParam. It may be NULL if there are no parameters to be registered.


Generated on Sun May 23 15:41:48 2004 for QOF by doxygen 1.3.6-20040222