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::MSG *, void *)
enum  TYPE {
  TYPE_None = 0, TYPE_System = 0x01, TYPE_Layout = 0x02, TYPE_Group = 0x04,
  TYPE_Layer = 0x08, TYPE_View = 0x10, TYPE_All = 0xFF
}

Public Member Functions

 OBJECT (OBJECT::TYPE type)
virtual ~OBJECT ()=0
void AddRef ()
void CallbackAdd (CBFUNC cbfunc, void *cbdata, OBJECT::TYPE objtypes)
void CallbackInvoke (const GRE::MSG &msg)
void CallbackInvoke (GRE::VIEW *view, GRE::MSG::ACTION action)
void CallbackInvoke (GRE::MSG::ACTION action, ELEMTYPE elemtype)
void CallbackInvoke (GRE::MSG::ACTION action, GRE::VIEW *view=0, ELEMTYPE elemtype=ELEMTYPE_Empty)
void CallbackRemove (CBFUNC cbfunc, void *cbdata, OBJECT::TYPE objtypes=TYPE_All)
bool Destroy (bool NotifyParent=true)
bool DestroyRequested () const
MICONSTRUCTGetIcon () const
void * GetPrivPtr (int idx) const
OBJECT::TYPE GetType () const
const char * GetTypeName (char *string) const
const char * GetTypeName () const
bool IsBeingDestroyed () const
bool IsTemporary () const
void Release ()
void SetPrivPtr (int idx, void *privptr)

Static Public Member Functions

static int AllocPrivIndex ()

Protected Member Functions

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

Private Member Functions

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

Detailed Description

Base class for other GRE "spatial" objects.


Member Typedef Documentation

typedef void(* GRE::OBJECT::CBFUNC)(const GRE::MSG *, void *)

Member Enumeration Documentation

GRE object types.

Enumerator:
TYPE_None 
TYPE_System 
TYPE_Layout 
TYPE_Group 
TYPE_Layer 
TYPE_View 
TYPE_All 

Reimplemented in GRE::LAYER.


Constructor & Destructor Documentation

GRE::OBJECT::OBJECT ( OBJECT::TYPE  type  )  [explicit]

Constructor.

Parameters:
type Object type to construct
virtual GRE::OBJECT::~OBJECT (  )  [pure virtual]

Destructor.


Member Function Documentation

void GRE::OBJECT::AddRef (  )  [inline]

Increment reference count.

static 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,
OBJECT::TYPE  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 OBJECT::TYPE_Group and OBJECT::TYPE_Layer specified. Then within the callback itself a determination of the object type may be done. Alternatively two callbacks might be used, one specifying OBJECT::TYPE_Group and the other specifying OBJECT::TYPE_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
void GRE::OBJECT::CallbackInvoke ( const GRE::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::MSG::ACTION  action 
) [inline]

Invoke callbacks on object and its ancestors.

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

void GRE::OBJECT::CallbackInvoke ( GRE::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.

void GRE::OBJECT::CallbackInvoke ( GRE::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.

void GRE::OBJECT::CallbackRemove ( CBFUNC  cbfunc,
void *  cbdata,
OBJECT::TYPE  objtypes = TYPE_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
bool GRE::OBJECT::CallbacksBeingInvoked (  )  const [inline, protected]

Determine if callbacks are currently being invoked on this object.

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
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.

MICONSTRUCT* GRE::OBJECT::GetIcon (  )  const [inline]

Get icon for this object type.

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()
OBJECT::TYPE GRE::OBJECT::GetType (  )  const [inline]

Get GRE object type.

const char* GRE::OBJECT::GetTypeName ( char *  string  )  const

Get name of this object type in string.

Returns:
Pointer to string provided.
Parameters:
string String to fill in
const char* GRE::OBJECT::GetTypeName (  )  const [inline]

Get name of this object type.

Returns:
Pointer to constant string.
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.

bool GRE::OBJECT::IsTemporary (  )  const [inline]

Determine if object is considered 'temporary'.

Temporary objects should not be saved or shown in list/treeview interface.

Reimplemented in GRE::LAYER_SKETCH.

void GRE::OBJECT::Release (  ) 

Decrement reference count, perform deferred destruction if requested and no remaining references.

void GRE::OBJECT::SetBeingDestroyed (  )  [inline, protected]

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

void GRE::OBJECT::SetDestroyRequest (  )  [inline, protected]

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

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.
void GRE::OBJECT::SetTemporary (  )  [inline, protected]

Set object as temporary.

virtual bool GRE::OBJECT::v_Destroy ( bool  NotifyParent  )  [private, pure virtual]

Overridables.

virtual MICONSTRUCT* 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 Sun Oct 7 21:34:44 2012 for TNTsdk 2012 by  doxygen 1.6.1