Public Types | Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes

Onyx::Properties::PropertyBase Class Reference

Base Property class, is essentially an abstract data container around Poco::DynamicAny. More...

#include <PropertyBase.h>

Inheritance diagram for Onyx::Properties::PropertyBase:
Onyx::Properties::DefaultProperty Onyx::Properties::SimpleProperty Onyx::Properties::ClassProperty Onyx::Properties::SimpleDefaultProperty Onyx::Properties::ClassMemberProperty< T > Onyx::Properties::SimpleClassProperty

Public Types

typedef Poco::SharedPtr
< PropertyBase
Ptr
 Typedef for shared pointers.

Public Member Functions

void addValidator (const std::string &name, Validator::Ptr validator)
 Add a new Validator to the Property.
const bool & areValidatorsEnabled ()
 Get whether or not validators are enabled for the Property.
void bind (PropertyBase *prop)
 Bind a passed Property's value to the Property, is used instead of the Property's own value.
void disableValidators ()
 Disable validators for the Property.
void enableValidators ()
 Enable validators for the Property.
const Poco::DynamicAny & get () const
 Get a reference to the underlying value.
const std::string & getGroup () const
 Get the group of the Property.
const std::string & getName () const
 Get the name of the Property.
template<typename T >
Poco::DynamicAny operator* (const T &other)
 Multiplication operator for multiplying the underlying value.
template<typename T >
Poco::DynamicAny & operator*= (const T &other)
 Mult assign operator for multiplying and assigning to the underlying value.
template<typename T >
Poco::DynamicAny operator+ (const T &other)
 Addition operator for adding the underlying value.
void operator++ ()
 Increment operator for incrementing the underlying value.
template<typename T >
Poco::DynamicAny & operator+= (const T &other)
 Add assign operator for adding to the underlying value.
template<typename T >
Poco::DynamicAny operator- (const T &other)
 Subtraction operator for subtracting the underlying value.
void operator-- ()
 Decrement operator for decrementing the underlying value.
template<typename T >
Poco::DynamicAny & operator-= (const T &other)
 Sub assign operator for subtracting from the underlying value.
template<typename T >
Poco::DynamicAny operator/ (const T &other)
 Division operator for dividing the underlying value.
template<typename T >
Poco::DynamicAny & operator/= (const T &other)
 Div assign operator for dividing and assigning to the underlying value.
Poco::DynamicAny & operator= (const PropertyBase &other)
 PropertyBase (const std::string &propName, const std::string &groupName="", const bool &validateAll=true)
 Default constructor, value will actually depend on the implicent conversion used (0 for numeric, empty string for strings).
 PropertyBase (const PropertyBase &other)
 Copy constructor.
void removeAllValidators ()
 Remove all Validators from the Property.
void removeBindings ()
 Unbind any properties that may use this Property's value, called on deconstruction.
void removeValidator (const std::string &name)
 Remove an added Validator.
void set (const Poco::DynamicAny &value, const bool &useOwnValidators=true)
 Set the Property's value, if the Property is bound to another, the value will be passed to the bound Property and the Property's own value will be unchanged.
void setGroup (const std::string &group)
 Set the group name of the Property.
void setValidateAll (const bool &alwaysValidateAll)
 Set whether or not the Property should always compare a value against all validators, rather than aborting when the first validator fails.
void unbind ()
const bool & validateAll () const
 Get whether or not the Property always check all validators and does not simply abort when the first fails.
virtual ~PropertyBase ()
 Destructor, unbinds this Property from any Properties that are binding it and releases the Property bound to this one, if one exists.

Data Fields

Poco::BasicEvent< const
PropertyValidationFailedEvent
validationFailedEvent
 Event fired when validation fails.
Poco::BasicEvent< const
PropertyChangedEvent
valueChangedEvent
 Event fired when the value of the Property changes.

Protected Member Functions

void checkValidators (const Poco::DynamicAny &value, std::vector< Poco::Exception > &exceptions)
 Member function called by implementations to see if a held value passes all validators.
void notifyBound (PropertyBase *prop)
 Notify a Property has been bound.
void notifyValidationFailed (const PropertyValidationFailedEvent &event)
 Special member function called when a Property's value is set and it fails validation which notifies any properties bound to the Property of the change.
void notifyValueSet (const PropertyChangedEvent &event)
 Special member function called when a Property's value is set which notifies any properties bound to the Property of the change.
void removeBinding (PropertyBase *prop)
 Notify this Property that the passed Property will no longer be using it's value, called on bind (if the binding property already has a Property) and unbind.
virtual void setImpl (const Poco::DynamicAny &value)=0
 Subclass specific implementation of the set member function.
virtual const Poco::DynamicAny & valueImpl ()=0
 Implementation specific member function, needs to be implemented by derived classes.

Protected Attributes

bool alwaysValidateAll
 Boolean used to determine if all validators will always be checked. If true, a value will be compared against all validators, rather than aborting once one fails.
std::set< PropertyBase * > boundTo
 Set of Properties that this Property's value is used by.
PropertyBaseboundValue
 Pointer to the Property whose value used by this Property instead of its own.
std::string group
 Group (type) of the Property.
std::string name
 Name of the Property;.
std::map< std::string,
Validator::Ptr
validators
 Map of validators assigned to the Property.
bool validatorsEnabled
 Boolean used to determine whether or not any added validators will be used, useful when going from an editor to a performance critical application.

Detailed Description

Base Property class, is essentially an abstract data container around Poco::DynamicAny.

This class acts as a general interface for further subclassing.

Remarks:
Cyclic Property value binding is not allowed.
Property names are immutable and cannot be changed once the Property has been created.
Warning:
The DynamicAny class can only hold certain classes by default (see Poco documentation for more information), custom types need to implement a specialization of DynamicAnyHolderImpl.

Member Typedef Documentation

Typedef for shared pointers.

Reimplemented in Onyx::Properties::ClassProperty, and Onyx::Properties::DefaultProperty.


Constructor & Destructor Documentation

Onyx::Properties::PropertyBase::PropertyBase ( const PropertyBase other  ) 

Copy constructor.

Parameters:
other Property to copy.
Onyx::Properties::PropertyBase::PropertyBase ( const std::string &  propName,
const std::string &  groupName = "",
const bool &  validateAll = true 
)

Default constructor, value will actually depend on the implicent conversion used (0 for numeric, empty string for strings).

Parameters:
propName Name of the Property.
groupName name of the group the Property belongs to.
validateAll Whether or not all validators should always be evaluated.
virtual Onyx::Properties::PropertyBase::~PropertyBase (  )  [virtual]

Destructor, unbinds this Property from any Properties that are binding it and releases the Property bound to this one, if one exists.


Member Function Documentation

void Onyx::Properties::PropertyBase::removeBinding ( PropertyBase prop  )  [protected]

Notify this Property that the passed Property will no longer be using it's value, called on bind (if the binding property already has a Property) and unbind.

Parameters:
prop Pointer to the Property that will no longer be bound to this Property.
void Onyx::Properties::PropertyBase::notifyBound ( PropertyBase prop  )  [protected]

Notify a Property has been bound.

Parameters:
prop The binding Property.
void Onyx::Properties::PropertyBase::notifyValueSet ( const PropertyChangedEvent event  )  [protected]

Special member function called when a Property's value is set which notifies any properties bound to the Property of the change.

Parameters:
event The event passed, it is passed from Property to Property.
Remarks:
This member function member function is recursive in nature and can result in multiple calls.
void Onyx::Properties::PropertyBase::notifyValidationFailed ( const PropertyValidationFailedEvent event  )  [protected]

Special member function called when a Property's value is set and it fails validation which notifies any properties bound to the Property of the change.

Parameters:
event The event passed, it is passed from Property to Property.
Remarks:
This member function member function is recursive in nature and can result in multiple calls.
void Onyx::Properties::PropertyBase::checkValidators ( const Poco::DynamicAny &  value,
std::vector< Poco::Exception > &  exceptions 
) [protected]

Member function called by implementations to see if a held value passes all validators.

Parameters:
value The value to be validated.
exceptions Reference to the vector in which to store exceptions.
Remarks:
This needs to be called from the set member function of derived classes.
virtual void Onyx::Properties::PropertyBase::setImpl ( const Poco::DynamicAny &  value  )  [protected, pure virtual]

Subclass specific implementation of the set member function.

Parameters:
value the new value for the Property.
Remarks:
This member function is called by set if the value is valid.

Implemented in Onyx::Properties::ClassMemberProperty< T >, Onyx::Properties::SimpleClassProperty, Onyx::Properties::SimpleDefaultProperty, and Onyx::Properties::SimpleProperty.

virtual const Poco::DynamicAny& Onyx::Properties::PropertyBase::valueImpl (  )  [protected, pure virtual]

Implementation specific member function, needs to be implemented by derived classes.

Implemented in Onyx::Properties::ClassMemberProperty< T >, Onyx::Properties::SimpleClassProperty, Onyx::Properties::SimpleDefaultProperty, and Onyx::Properties::SimpleProperty.

const std::string& Onyx::Properties::PropertyBase::getName (  )  const

Get the name of the Property.

const std::string& Onyx::Properties::PropertyBase::getGroup (  )  const

Get the group of the Property.

void Onyx::Properties::PropertyBase::setGroup ( const std::string &  group  ) 

Set the group name of the Property.

Parameters:
group Name of the group this Property belongs to.
const bool& Onyx::Properties::PropertyBase::validateAll (  )  const

Get whether or not the Property always check all validators and does not simply abort when the first fails.

void Onyx::Properties::PropertyBase::setValidateAll ( const bool &  alwaysValidateAll  ) 

Set whether or not the Property should always compare a value against all validators, rather than aborting when the first validator fails.

Parameters:
alwaysValidateAll If true when set is called the value will always be compared against every validator.
const bool& Onyx::Properties::PropertyBase::areValidatorsEnabled (  ) 

Get whether or not validators are enabled for the Property.

void Onyx::Properties::PropertyBase::enableValidators (  ) 

Enable validators for the Property.

void Onyx::Properties::PropertyBase::disableValidators (  ) 

Disable validators for the Property.

void Onyx::Properties::PropertyBase::set ( const Poco::DynamicAny &  value,
const bool &  useOwnValidators = true 
)

Set the Property's value, if the Property is bound to another, the value will be passed to the bound Property and the Property's own value will be unchanged.

Parameters:
value The value to set the Property to, the value is only changed if all validators conditions are met.
useOwnValidators If this Property is currently using the value of another property (bound) this determines whether or not to apply the Property's own Validators to the value before passing the value to the bound Property.
Remarks:
Only values that can be stored in a DynamicAny can be used.
No type checking is done to ensure the Property's type remains consistent, a TypeMatcher Validator can be used for ensuring type consistency.
This is a generic member function that handles notifications, the actual setting of the value is done in setImpl.
void Onyx::Properties::PropertyBase::addValidator ( const std::string &  name,
Validator::Ptr  validator 
)

Add a new Validator to the Property.

Parameters:
name Name of the Validator.
validator The Validator to add, as a SharedPtr.
Remarks:
If a Validator named name is already in the map, an InvalidArgumentException will be thrown.
void Onyx::Properties::PropertyBase::removeValidator ( const std::string &  name  ) 

Remove an added Validator.

Parameters:
name Name of the Validator to remove.
Remarks:
This member function will do nothing if no Validator named name has been added.
void Onyx::Properties::PropertyBase::removeAllValidators (  ) 

Remove all Validators from the Property.

void Onyx::Properties::PropertyBase::bind ( PropertyBase prop  ) 

Bind a passed Property's value to the Property, is used instead of the Property's own value.

Parameters:
prop Pointer to the Property's value to use.
Remarks:
This member function insures that no cycle exists in Property value dependencies, and will throw an LogicException if it detects one.
void Onyx::Properties::PropertyBase::unbind (  ) 
void Onyx::Properties::PropertyBase::removeBindings (  ) 

Unbind any properties that may use this Property's value, called on deconstruction.

const Poco::DynamicAny& Onyx::Properties::PropertyBase::get (  )  const

Get a reference to the underlying value.

Poco::DynamicAny& Onyx::Properties::PropertyBase::operator= ( const PropertyBase other  ) 

References get().

template<typename T >
Poco::DynamicAny Onyx::Properties::PropertyBase::operator+ ( const T &  other  ) 

Addition operator for adding the underlying value.

Parameters:
other The value to add.
Remarks:
This behaves exactly like the DynamicAny + operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny Onyx::Properties::PropertyBase::operator- ( const T &  other  ) 

Subtraction operator for subtracting the underlying value.

Parameters:
other The value to subtract.
Remarks:
This behaves exactly like the DynamicAny - operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny Onyx::Properties::PropertyBase::operator* ( const T &  other  ) 

Multiplication operator for multiplying the underlying value.

Parameters:
other The value to multiply by.
Remarks:
This behaves exactly like the DynamicAny * operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny Onyx::Properties::PropertyBase::operator/ ( const T &  other  ) 

Division operator for dividing the underlying value.

Parameters:
other The value to divide by.
Remarks:
This behaves exactly like the DynamicAny / operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny& Onyx::Properties::PropertyBase::operator+= ( const T &  other  ) 

Add assign operator for adding to the underlying value.

Parameters:
other The value to add.
Remarks:
This behaves exactly like the DynamicAny += operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny& Onyx::Properties::PropertyBase::operator-= ( const T &  other  ) 

Sub assign operator for subtracting from the underlying value.

Parameters:
other The value to subtract.
Remarks:
This behaves exactly like the DynamicAny -= operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny& Onyx::Properties::PropertyBase::operator*= ( const T &  other  ) 

Mult assign operator for multiplying and assigning to the underlying value.

Parameters:
other The value to multiply by.
Remarks:
This behaves exactly like the DynamicAny *= operator, and will only work if the underlying types make sense.
template<typename T >
Poco::DynamicAny& Onyx::Properties::PropertyBase::operator/= ( const T &  other  ) 

Div assign operator for dividing and assigning to the underlying value.

Parameters:
other The value to divide by.
Remarks:
This behaves exactly like the DynamicAny /= operator, and will only work if the underlying types make sense.
void Onyx::Properties::PropertyBase::operator++ (  ) 

Increment operator for incrementing the underlying value.

Remarks:
This behaves exactly like the DynamicAny ++ operator, and will only work if the underlying type make sense.
void Onyx::Properties::PropertyBase::operator-- (  ) 

Decrement operator for decrementing the underlying value.

Remarks:
This behaves exactly like the DynamicAny -- operator, and will only work if the underlying type make sense.

Field Documentation

std::string Onyx::Properties::PropertyBase::name [protected]

Name of the Property;.

std::string Onyx::Properties::PropertyBase::group [protected]

Group (type) of the Property.

Pointer to the Property whose value used by this Property instead of its own.

std::map<std::string, Validator::Ptr> Onyx::Properties::PropertyBase::validators [protected]

Map of validators assigned to the Property.

Set of Properties that this Property's value is used by.

Boolean used to determine if all validators will always be checked. If true, a value will be compared against all validators, rather than aborting once one fails.

Boolean used to determine whether or not any added validators will be used, useful when going from an editor to a performance critical application.

Event fired when the value of the Property changes.

Event fired when validation fails.


The documentation for this class was generated from the following file: