SophiaFramework UNIVERSE 5.3 |
#include <SFXHierarchyProperty.h.hpp>
class SFXHierarchyProperty;
SFMTYPEDEFCLASS(SFXHierarchyProperty)
This class consists of a hash map which has a UInt32 key of the property type and a value of the property SFXHierarchyProperty::ValueRec (at most 4 byte).
As the name implies, the SFXHierarchyProperty class works as hierarchical.
For example, SFZTableView, SFOTableViewColumn, and SFOTableCellReactor classes hold this property. The former property is the parent of the latter one, and the property values are inherited as hierarchical.
If a parent and a child have a same key and diffrent values, the parent's value is as-is from the parent view, but the value is overridden by the child's value from the child view.
The SFXHierarchyProperty::SetParent function sets a parent of the property. A property without a parent is called as a root.
The following table represents a example of how font values (the key is SFLPROP_FONT) are seen in each classes.
Class name | Property value (that is set) | Apparent property value |
---|---|---|
SFZTableView | AEE_FONT_LARGE | AEE_FONT_LARGE |
SFOTableViewColumn | None | AEE_FONT_LARGE |
SFOTableCellReactor | AEE_FONT_NORMAL | AEE_FONT_NORMAL |
If a property key is not defined in any ancestors and the property itself, the values of the key will be indeterminate and interpreted in the manner of each classes.
Property value is a SFXHierarchyProperty::ValueRec union. Accessing the members of it can save type casting.
SFXHierarchyProperty::ValueRec | SFXHierarchyProperty::SetParent | SFZTableView | SFOTableViewColumn | SFOTableCellReactor
Constructor/Destructor |
---|
SFXHierarchyProperty( Void ) Constructor of the SFXHierarchyProperty class.
|
~SFXHierarchyProperty( Void ) Destructor of the SFXHierarchyProperty class.
|
Public Functions | |
---|---|
Bool |
Contains(
UInt32 key
, Bool recursive = true
) Check if a specified property key is contained.
|
ValueRec |
Get(
UInt32 key
, BoolPtr found = null
, Bool recursive = true
) Get a property value for a specified property key.
|
Bool |
HasParent( Void ) Check if a parent property is set.
|
SFCError |
Set(
UInt32 key
, ValueRec value
) Set the property value for the specified property key.
|
Void |
SetParent(
SFXHierarchyPropertyConstPtr parent
) Set a parent property.
|
Types |
---|
ValueRec Union which represents a property value.
|
[ public, explicit ] SFXHierarchyProperty(Void);
[ public ] ~SFXHierarchyProperty(Void);
[ public, const ] Bool Contains( UInt32 key // property key Bool recursive = true // whether climb up the tree recursively );
If the recursive argument is true, searching will be continued with climbing up the ancestors until the key is hit.
Otherwise, performed only in this property.
The SFXHierarchyProperty::Get function can also search keys.
In the default, the recursive argument is true.
[ public, const ] ValueRec Get( UInt32 key // property key BoolPtr found = null // whether the key is found or not Bool recursive = true // whether climb up the parent tree recursively );
Property value (SFXHierarchyProperty::ValueRec).
If the recursive argument is true, searching will be continued with climbing up the parent tree until the key is hit. When the searching is success, the property value is gotten. Otherwise, null (the type is SFXHierarchyProperty::ValueRec).
If the recursive argument is false, performed only in this property.
The found argument checks whether the key is found or not. This is how you can distinguish whether the property value actually hold null value, or just the key is not found.
In the default, the found argument is null pointer, and the recursive is true.
[ public, const ] Bool HasParent(Void);
Since the SFXHierarchyProperty::ValueRec union has various conversion constructors, the property value may be able to set a non union value.
Usage of ValueRec(SFXRGBColorConstRef param) conversion constructor
SFXHierarchyProperty property;
// Set the background color to blue
property.Set(SFLPROP_BACKGROUND_COLOR, SFXRGBColor(0x00, 0x00, 0xBB, 0x00));
[ public, const ] Void SetParent( SFXHierarchyPropertyConstPtr parent // parent property );
Setting a parent property makes the properties work hierarchical.
SFMTYPEDEFUNION(ValueRec) union ValueRec { // Member variables SIntN sn; UIntN un; SInt32 s32; UInt32 u32; SInt16 s16; UInt16 u16; SInt08 s08; UInt08 u08; Bool flag; VoidPtr ptr; AEEFont font; SFXRGBColor::AtomRec color; SFXSize::AtomRec size; SFXGrid::AtomRec grid; // Default constructor ValueRec (Void); // Conversion constructors ValueRec (ValueRecConstRef param); ValueRec (SIntNConstRef param); ValueRec (UIntNConstRef param); ValueRec (SInt32ConstRef param); ValueRec (UInt32ConstRef param); ValueRec (SInt16ConstRef param); ValueRec (UInt16ConstRef param); ValueRec (SInt08ConstRef param); ValueRec (UInt08ConstRef param); ValueRec (VoidPtrConstRef param); ValueRec (SFXRGBColorConstRef param); ValueRec (SFXRGBColor::AtomRecConstRef param); ValueRec (SFXSizeConstRef param); ValueRec (SFXSize::AtomRecConstRef param); ValueRec (SFXGridConstRef param); ValueRec (SFXGrid::AtomRecConstRef param); // Set functions ValueRecRef Set (ValueRecConstRef param); ValueRecRef Set (SIntNConstRef param); ValueRecRef Set (UIntNConstRef param); ValueRecRef Set (SInt32ConstRef param); ValueRecRef Set (UInt32ConstRef param); ValueRecRef Set (SInt16ConstRef param); ValueRecRef Set (UInt16ConstRef param); ValueRecRef Set (SInt08ConstRef param); ValueRecRef Set (UInt08ConstRef param); ValueRecRef Set (VoidPtrConstRef param); ValueRecRef Set (SFXRGBColorConstRef param); ValueRecRef Set (SFXRGBColor::AtomRecConstRef param); ValueRecRef Set (SFXSizeConstRef param); ValueRecRef Set (SFXSize::AtomRecConstRef param); ValueRecRef Set (SFXGridConstRef param); ValueRecRef Set (SFXGrid::AtomRecConstRef param); // Assign operators ValueRecRef operator= (ValueRecConstRef param); ValueRecRef operator= (SIntNConstRef param); ValueRecRef operator= (UIntNConstRef param); ValueRecRef operator= (SInt32ConstRef param); ValueRecRef operator= (UInt32ConstRef param); ValueRecRef operator= (SInt16ConstRef param); ValueRecRef operator= (UInt16ConstRef param); ValueRecRef operator= (SInt08ConstRef param); ValueRecRef operator= (UInt08ConstRef param); ValueRecRef operator= (VoidPtrConstRef param); ValueRecRef operator= (SFXRGBColorConstRef param); ValueRecRef operator= (SFXRGBColor::AtomRecConstRef param); ValueRecRef operator= (SFXSizeConstRef param); ValueRecRef operator= (SFXSize::AtomRecConstRef param); ValueRecRef operator= (SFXGridConstRef param); ValueRecRef operator= (SFXGrid::AtomRecConstRef param); };
A property value is a union which has at most 4 byte size members. The union has various set functions, conversion constructors, and assign operators for various types.
To get the value from the union, access its member variable.
SFXRGBColor white(0xFF, 0xFF, 0xFF, 0x00); SFXRGBColor color; SFXHierarchyProperty::ValueRec value; // Set color to white (Set function). value.Set(white); // Access color member variable. color = value.color; if (color == white) { TRACE("color is white."); } // Set color to white (Assign operator). value = white; // Access color member variable. color = value.color; if (color == white) { TRACE("color is white, again."); } // Conversion constructor. SFXHierarchyProperty::ValueRec another(white); // Access color member variable. color = another.color; if (color == white) { TRACE("color is white, again and again."); }
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |