GRE_OBJECT Class Reference

Base class for other GRE "spatial" objects. More...

#include <gre/objectbase.h>

Inheritance diagram for GRE_OBJECT:

Inheritance graph
[legend]
List of all members.

Public Types

typedef void(* CBFUNC )(const GRE_CALLBACK_MSG *, void *)

Public Member Functions

void CallbackAdd (CBFUNC cbfunc, void *cbdata, GRE_OBJTYPE objtypes)
void CallbackInvoke (const GRE_CALLBACK_MSG &msg)
void CallbackInvoke (GRE_VIEW *view, GRE_CALLBACK_MSG::ACTION action)
void CallbackInvoke (GRE_CALLBACK_MSG::ACTION action, ELEMTYPE elemtype)
void CallbackInvoke (GRE_CALLBACK_MSG::ACTION action, GRE_VIEW *view=0, ELEMTYPE elemtype=ELEMTYPE_Empty)
void CallbackRemove (CBFUNC cbfunc, void *cbdata, GRE_OBJTYPE objtypes=GRE_OBJTYPE_All)
bool Destroy (bool NotifyParent=true)
bool DestroyRequested () const
MICON GetIcon () const
void * GetPrivPtr (int idx) const
GRE_OBJTYPE GetType () const
char * GetTypeName (char *string)
const char * GetTypeName () const
 GRE_OBJECT (GRE_OBJTYPE type)
bool IsBeingDestroyed () const
void SetPrivPtr (int idx, void *privptr)
virtual ~GRE_OBJECT ()=0

Static Public Member Functions

int AllocPrivIndex ()

Protected Member Functions

bool CallbacksBeingInvoked () const
void SetBeingDestroyed ()
void SetDestroyRequest ()

Private Member Functions

virtual bool v_Destroy (bool NotifyParent)=0
virtual MICON v_GetIcon () const =0
virtual const char * v_GetTypeName () const =0

Detailed Description

Base class for other GRE "spatial" objects.

Definition at line 43 of file objectbase.h.


Member Typedef Documentation

typedef void(* GRE_OBJECT::CBFUNC)(const GRE_CALLBACK_MSG *, void *)
 

Definition at line 47 of file objectbase.h.


Constructor & Destructor Documentation

GRE_OBJECT::GRE_OBJECT GRE_OBJTYPE  type  )  [explicit]
 

Constructor.

Parameters:
type  Object type to construct

virtual GRE_OBJECT::~GRE_OBJECT  )  [pure virtual]
 

Destructor.


Member Function Documentation

int GRE_OBJECT::AllocPrivIndex  )  [static]
 

Allocate index into private pointer array to attach to.

See also:
GetPrivPtr, SetPrivPtr It is often desirable for a process or library module to attach "private" data to one or more GRE objects. This can be done using AllocPrivIndex() to allocate an entry into each object's private pointer array. This method should only be called the first time the private index is needed. It is the programmer's responsibility to retain this private index value. Once a private index is allocated, use SetPrivPtr() to attach data to any GRE object and GetPrivPtr() to retrieve previously attached data.

void GRE_OBJECT::CallbackAdd CBFUNC  cbfunc,
void *  cbdata,
GRE_OBJTYPE  objtypes
[inline]
 

Add callback function to object.

The new callback function will be added to the head of the list.

Callbacks may be added to any GRE object. When a callback occurs for a particular object the message is sent to that object's callback list and any "ancestor" object's callback lists as well. A callback will be called if the object type for the message was included in the object types specified when the callback was added. This often eliminates the need to add callbacks to every GRE object which is created. If a program creates a single group and needs information about the group and layers within it then a callback can be added to the group with GRE_OBJTYPE_Group and GRE_OBJTYPE_Layer specified. Then within the callback itself a determination of the object type may be done. Alternatively two callbacks might be used, one specifying GRE_OBJTYPE_Group and the other specifying GRE_OBJTYPE_Layer. Both callbacks would be added to the group, but no check of the object type would be needed within the callback since only one object type was specified when each callback was added.

Parameters:
cbfunc  Callback function
cbdata  "Hook" data to pass to callback
objtypes  Object types for which messages are requested

Definition at line 111 of file objectbase.h.

void GRE_OBJECT::CallbackInvoke const GRE_CALLBACK_MSG msg  ) 
 

Invoke callbacks on object and its ancestors.

This method is generally only invoked from within the GRE library itself.

void GRE_OBJECT::CallbackInvoke GRE_VIEW view,
GRE_CALLBACK_MSG::ACTION  action
[inline]
 

Invoke callbacks on object and its ancestors.

This method is generally only invoked from within the GRE library itself.

Definition at line 134 of file objectbase.h.

void GRE_OBJECT::CallbackInvoke GRE_CALLBACK_MSG::ACTION  action,
ELEMTYPE  elemtype
[inline]
 

Invoke callbacks on object and its ancestors.

This method is generally only invoked from within the GRE library itself.

Definition at line 127 of file objectbase.h.

void GRE_OBJECT::CallbackInvoke GRE_CALLBACK_MSG::ACTION  action,
GRE_VIEW view = 0,
ELEMTYPE  elemtype = ELEMTYPE_Empty
[inline]
 

Invoke callbacks on object and its ancestors.

This method is generally only invoked from within the GRE library itself.

Definition at line 119 of file objectbase.h.

void GRE_OBJECT::CallbackRemove CBFUNC  cbfunc,
void *  cbdata,
GRE_OBJTYPE  objtypes = GRE_OBJTYPE_All
[inline]
 

Remove callback function.

All callbacks are automatically removed when the object is destroyed. However, if the data specified when the callback was added is freed before the object is destroyed, all callbacks referencing that data should be removed. In this case, the cbfunc may be specified as NULL and the cbdata should be the pointer about to be freed. This will remove all callbacks referencing that pointer in a single step.

Parameters:
cbfunc  Callback function, matching CallbackAdd, or NULL to match all
cbdata  Callback data, matching CallbackAdd
objtypes  Object types

Definition at line 152 of file objectbase.h.

bool GRE_OBJECT::CallbacksBeingInvoked  )  const [inline, protected]
 

Determine if callbacks are currently being invoked on this object.

Definition at line 202 of file objectbase.h.

bool GRE_OBJECT::Destroy bool  NotifyParent = true  )  [inline]
 

Request destruction of this object.

Returns:
true if destroyed, false if destruction deferred. If an object is dynamically created then unless the destruction occurs in the same function as creation the Destroy() method should be used instead. This is especially true if destruction is to be performed within a GRE callback. Using delete on an object withing a callback may result in unpredictable behavior.
Parameters:
NotifyParent  Notify parent of child's destruction if appropriate

Definition at line 77 of file objectbase.h.

bool GRE_OBJECT::DestroyRequested  )  const [inline]
 

Determine if destruction has been requested for this object.

Sometimes a callback may be invoked on an object after destruction has been requested on that object. This may occur if destruction occurs in a callback and more callbacks are in the list after the one destroying the object. In order to avoid unwanted processing or errors it may be necessary to determine if an object has been requested to be destroyed. This is only useful within a callback since once the callbacks are completed the destruction will finish and thus the object will no longer exist.

Definition at line 166 of file objectbase.h.

MICON GRE_OBJECT::GetIcon  )  const [inline]
 

Get icon for this object type.

Definition at line 82 of file objectbase.h.

void* GRE_OBJECT::GetPrivPtr int  idx  )  const [inline]
 

Get "private" pointer for this object.

See also:
AllocPrivIndex, SetPrivPtr
Parameters:
idx  Private index obtained from AllocPrivIndex()

Definition at line 171 of file objectbase.h.

GRE_OBJTYPE GRE_OBJECT::GetType  )  const [inline]
 

Get GRE object type.

Definition at line 176 of file objectbase.h.

char* GRE_OBJECT::GetTypeName char *  string  )  [inline]
 

Get name of this object type in string.

Returns:
Pointer to string provided.
Parameters:
string  String to fill in

Definition at line 92 of file objectbase.h.

const char* GRE_OBJECT::GetTypeName  )  const [inline]
 

Get name of this object type.

Returns:
Pointer to constant string.

Definition at line 87 of file objectbase.h.

bool GRE_OBJECT::IsBeingDestroyed  )  const [inline]
 

Determine if object in process of being destroyed.

Sometimes a callback may be invoked on an object after destruction has begun on that object. In order to avoid unwanted processing or errors it may be necessary to determine if an object is in the process of being destroyed. This is only useful within a callback since once the callbacks are completed the destruction will finish and thus the object will no longer exist.

Definition at line 185 of file objectbase.h.

void GRE_OBJECT::SetBeingDestroyed  )  [inline, protected]
 

Notify object that is being destroyed, usually called by Destroy() method.

Definition at line 206 of file objectbase.h.

void GRE_OBJECT::SetDestroyRequest  )  [inline, protected]
 

Request destruction of object, usually called by Destroy() method.

Definition at line 210 of file objectbase.h.

void GRE_OBJECT::SetPrivPtr int  idx,
void *  privptr
[inline]
 

Set "private" pointer for this object.

When an object is destroyed, the private pointers are NOT freed by the GRE system. Thus it is the programmers responsibility to see that allocated data attached to an object is freed at the appropriate time, usually by checking for ACTION_Destroy in the callback message.

See also:
GetPrivPtr, AllocPrivIndex
Parameters:
idx  Private index obtained from AllocPrivIndex()
privptr  Pointer value to set.

Definition at line 194 of file objectbase.h.

virtual bool GRE_OBJECT::v_Destroy bool  NotifyParent  )  [private, pure virtual]
 

< GENERATING_DOXYGEN_OUTPUT Overridables.

virtual MICON GRE_OBJECT::v_GetIcon  )  const [private, pure virtual]
 

virtual const char* GRE_OBJECT::v_GetTypeName  )  const [private, pure virtual]
 


The documentation for this class was generated from the following file:
Generated on Tue Dec 14 13:19:54 2004 for TNTsdk by  doxygen 1.3.8-20040913