Class: cObject¶
Include: Built in; no package required.
Root DataFlex object class for object handles, hierarchy, lifecycle hooks, child objects, and delegation.
Hierarchy¶
- cObject
Package: Built in; no package required.
Description¶
cObject is the root DataFlex object class. It provides object identity, naming, parent/child hierarchy, construction and destruction hooks, dynamic child creation, delegation, neighborhood lookup, and class inspection.
Object lifecycle¶
Construct_Objectruns during object construction.End_Construct_Objectruns after object construction has finished.Destroydestroys dynamically created objects.- After
Destroy, do not reuse the old handle. - The null object and desktop object cannot be destroyed and raise a DataFlex error.
Dynamic objects¶
Create and CreateNamed create child objects at runtime and return a Handle. CreateNamed requires a non-empty local name; empty names raise a DataFlex error.
Object identity and hierarchy¶
Object_Id returns the current object handle. Name returns the qualified object name, such as oMain.oChild; setting it changes the object's local name. Object_Label returns the local label, such as oChild. Parent identifies the parent object, Child_Count returns the number of direct children, and ChildByIndex returns a child by position.
ChildByIndex uses zero-based indexes and raises a DataFlex error when the index is below zero or greater than or equal to Child_Count.
Delegation and neighborhood¶
Delegation_Mode controls unknown-message delegation:
DELEGATE_TO_PARENTdelegates to the parent.NO_DELEGATE_OR_ERRORstops without raising an error.NO_DELEGATIONraises a DataFlex error.RETURN_INVALID_MESSAGEreturns the invalid message value.DELEGATE_PRIOR_LEVELdelegates to the prior object in the call stack.
peNeighborhood controls object-name visibility:
nhNodoes not participate in a neighborhood.nhPublicallows descendant objects to address each other.nhPrivatecreates a private neighborhood where descendants cannot address each other.
Class inspection¶
Class returns the class id for this object. Base_Class returns the parent class id for this object's class. ObjectClass returns this object's class id, resolving cloned class information to the original class where applicable. ClassSuperClass returns the parent class id for a class reference. IsClassOfClass returns a Boolean indicating whether one class is the same as, or derives from, another class. IsObjectOfClass returns a Boolean indicating whether this object is an instance of the requested class.
Examples¶
Static object tree¶
Object oMain is a cObject
Object oChild is a cObject
End_Object
End_Object
Dynamic object¶
Procedure CreateDynamicObject
Handle hoObj
Get CreateNamed (RefClass(cObject)) "oDynamic" to hoObj
Send Destroy of hoObj
End_Procedure