The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
proj_classes.h File Reference

Defines interfaces a project Class system for class hierarchies in 'C'. More...

#include <projectcommon.h>
#include <assimobj.h>
#include <glib.h>
Include dependency graph for proj_classes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MALLOCBASECLASS(Cclass)   ((Cclass *) proj_class_new(sizeof(Cclass), #Cclass))
 Allocate memory for a C-class object of base class class G(not to be further subclassed) - and register it with our C-Class system. More...
 
#define MALLOCCLASS(Cclass, size)   ((Cclass *) proj_class_new(size, #Cclass))
 Allocate memory for an object (which might be further subclassed) - and register it with our C-Class system. More...
 
#define CASTTOCLASS(Cclass, obj)   ((Cclass *) proj_class_castas(obj, #Cclass))
 Safely cast 'obj' to C-class 'class' - verifying that it was registerd as being of type class More...
 
#define NEWSUBCLASS(Cclass, obj)   ((Cclass *) proj_class_register_subclassed(obj, #Cclass))
 
#define CASTTOCONSTCLASS(Cclass, obj)   ((const Cclass *) proj_class_castasconst(obj, #Cclass))
 Safely cast 'obj' to const C-class 'class' - verifying that it was registered as being of type class More...
 
#define OBJ_IS_A(obj, Cclass)   proj_class_is_a(obj, Cclass)
 
#define FREECLASSOBJ(obj)   {proj_class_free(obj); obj = NULL;}
 Free a C-class object. More...
 
#define DEBUGVAR   __class_debug_count
 
#define DEBUGDECLARATIONS
 
#define BINDDEBUG(Cclass)   {if (!__class_debug_registered) {proj_class_register_debug_counter(#Cclass, &__class_debug_count); __class_debug_registered = TRUE;};}
 BINDDEBUG is for telling the class system where the debug variable for this class is - put it in the base constructor for the class. More...
 
#define DEBUG   (DEBUGVAR)
 
#define DEBUGMSG(...)   {if (DEBUG) {g_debug(__VA_ARGS__);};}
 
#define DEBUGMSGn(n,...)   {if (DEBUG >= (n)) {g_debug(__VA_ARGS__);};}
 
#define DEBUGMSG1(...)   DEBUGMSG ( __VA_ARGS__)
 
#define DEBUGMSG2(...)   DEBUGMSGn(2, __VA_ARGS__)
 
#define DEBUGMSG3(...)   DEBUGMSGn(3, __VA_ARGS__)
 
#define DEBUGMSG4(...)   DEBUGMSGn(4, __VA_ARGS__)
 
#define DEBUGMSG5(...)   DEBUGMSGn(5, __VA_ARGS__)
 
#define DUMP(prefix, obj, suffix)   {proj_class_debug_dump(prefix, obj, suffix);}
 
#define DUMP1(prefix, obj, suffix)   {if (DEBUG>=1) {DUMP(prefix, obj, suffix);};}
 
#define DUMP2(prefix, obj, suffix)   {if (DEBUG>=2) {DUMP(prefix, obj, suffix);};}
 
#define DUMP3(prefix, obj, suffix)   {if (DEBUG>=3) {DUMP(prefix, obj, suffix);};}
 
#define DUMP4(prefix, obj, suffix)   {if (DEBUG>=4) {DUMP(prefix, obj, suffix);};}
 
#define DUMP5(prefix, obj, suffix)   {if (DEBUG>=5) {DUMP(prefix, obj, suffix);};}
 

Functions

WINEXPORT gpointer proj_class_new (gsize objsize, const char *static_classname)
 Malloc a new object and register it in our class system. More...
 
WINEXPORT void proj_class_dissociate (gpointer object)
 Dissociate an object from the C class system (typically coupled with freeing it). More...
 
WINEXPORT void proj_class_free (gpointer object)
 Free a registered object from our class system. More...
 
WINEXPORT void proj_class_register_object (gpointer object, const char *static_classname)
 Log the creation of a new object, and its association with a given type. More...
 
WINEXPORT gboolean proj_class_is_a (gconstpointer object, const char *castclass)
 Return TRUE if the given object ISA castclass object. More...
 
WINEXPORT gpointer proj_class_castas (gpointer object, const char *castclass)
 "Safely" cast an object to a const object of the given C-class. More...
 
WINEXPORT gconstpointer proj_class_castasconst (gconstpointer object, const char *castclass)
 "Safely" cast an object to a const object of the given C-class. More...
 
WINEXPORT gpointer proj_class_register_subclassed (gpointer object, const char *static_subclassname)
 Log the creation of a subclassed object from a superclassed object. More...
 
WINEXPORT void proj_class_quark_add_superclass_relationship (GQuark superclass, GQuark subclass)
 Register a superclass/subclass relationship in our type system (using Quarks of the classes)) More...
 
WINEXPORT gboolean proj_class_quark_is_a (GQuark objectclass, GQuark testclass)
 Determine whether an 'objectclass' ISA member of 'testclass' - with quarks of types as arguments Since this little C-class system only supports single-inheritance, this isn't exactly rocket science. More...
 
WINEXPORT const char * proj_class_classname (gconstpointer object)
 Return the class name of one of our managed objects. More...
 
WINEXPORT void proj_class_register_debug_counter (const char *Cclass, guint *debugcount)
 
WINEXPORT void proj_class_incr_debug (const char *Cclass)
 Increment debug level for this class and all its subclasses by one. More...
 
WINEXPORT void proj_class_decr_debug (const char *Cclass)
 Decrement debug level for this class and all its subclasses by one. More...
 
WINEXPORT void proj_class_debug_dump (const char *prefix, const AssimObj *obj, const char *suffix)
 Send the object in question to g_debug() for printing... More...
 
WINEXPORT void proj_class_dump_live_objects (void)
 Dump all live C class objects (address and Class) More...
 
WINEXPORT guint32 proj_class_live_object_count (void)
 Return the count of live C class objects. More...
 
WINEXPORT guint32 proj_class_max_object_count (void)
 Return the maximum number of live C class objects that we've ever had. More...
 
WINEXPORT void proj_class_finalize_sys (void)
 Shut down (finalize) our object class system. Only do on shutdown to make valgrind happy :-D. More...
 

Detailed Description

Defines interfaces a project Class system for class hierarchies in 'C'.

We have a variety of classes and subclasses which we use, and this class system permits us to track them and catch errors in casting, parameter passing, etc.

This file is part of the Assimilation Project.

Author
Copyright © 2011, 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file proj_classes.h.