Property System Overview
Written by Owen   
Saturday, 14 August 2010 15:04

The Onyx.System package provides a very flexible Property system.   Classes for different types of Properties, an abstract base class for classes that have Properties, and a class for storing and managing Properties are provided.  Property values are retrieved and for some classes stored as Poco::DynamicAnys.  This means that any types used by the Property classes must be compatible with Poco::DynamicAny.  Poco::DynamicAny requirements can be found here.

The following abstract Property types are available.

The PropertyBase class is the Base for all Property subclasses.  It provides the core functionality available to all Properties such as:

  • Getting the name of a Property.
  • Getting/Setting the group a Property belongs to.
  • Getting/Setting the value of the Property .
  • Adding and managing validators and Property validation.
  • Provides Property binding.
  • Provides events for when the Property's value changes and when validation fails.

DefaultProperty adds functionality for storing a default value in the Property and resetting the Property's value to that Property.  ClassProperty is derived from DefaultProperty and adds functionality for binding a Property to a class instance.

The SimpleProperty class is a concrete implementation of PropertyBase and much like SimpleDefaultProperty and SimpleClassProperty stores its value within a Poco::DynamicAny.

ClassMemberProperty is a special subclass of ClassProperty that is intended to be used with a class derived from PropertyHolder.  This Property type wraps a class member.  It is very useful in the fact that it provides the end developer with the ability to access a class member just like they would a Property while maintaining the more performance oriented option of accessing the member using traditional get member functions.

The PropertyMap template class also provides some extremely useful features for managing groups of Properties.  There are already several typedefed instances for the 3 base Property types and a specialization specifically for use with ClassProperties since their construction is a little bit more complicated.  I highly recomend reading over the class documentation to learn more about its features.

Important things to remember:

  • Once a Property's name has been set in the constructor it cannot be changed.
  • Keep pointers to Properties, not their values.
  • Converting to other types from the type originally held by a DynamicAny is much more expensive than simply extracting the value as its original type.
  • Use ClassMemberProperties when possible.
Last Updated on Saturday, 14 August 2010 16:05

Login Form

Valid XHTML & CSS | Template Design ah-68 | Copyright © 2009 by Firma