template MyValueType> class M6Property

Property template

Public Fields

typedef MyValueType MyValueType
For the convenience of client code

Public

1 Construction
M6Property(MyValueType initValue)
Unvalidated constructor
template M6Property( MyValueType initValue, MyValidatorObject& validator, int (MyValidatorObject::* method)(MyValueType))
Validated constructor
2 Accessors
MyValueType getValue()
get the value
3 Mutators
int setValue(MyValueType newValue)
try to the value
template void addListener(MyListenerObject& listener, void (MyListenerObject::* method)(MyValueType))
Add a listener
template void delListener(MyListenerObject& listener, void (MyListenerObject::* method)(MyValueType))
Delete a listener

Private Fields

std::list listeners
MyValidator validator
MyValueType value

Documentation

Property template. A wrapper for a value (the property type) that allows a "validation method" and "listener methods" to be associated with it.

A validator method is called whenever an attempt is made to set the property's value. If this returns 0 the value is changed. If not, the value is unchanged. In either case the value returned by the validator method is returned to the client code.

Whenever a property value changes, all current listener methods are invoked with the updated value.

typedef MyValueType MyValueType
For the convenience of client code

1 Construction

M6Property(MyValueType initValue)
Unvalidated constructor
Parameters:
initValue - the initial value of the property

template M6Property( MyValueType initValue, MyValidatorObject& validator, int (MyValidatorObject::* method)(MyValueType))
Validated constructor. Client code looks like "makeValidatorCallback(*this, &Class::method)".
Parameters:
initValue - the initial value of the property
validator - validator object
method - the validation method

the method prototype must:

  • be compatable with int (Class::* method)(Value new)
  • return 0 or an error code for use by application

2 Accessors

MyValueType getValue()
get the value

3 Mutators

int setValue(MyValueType newValue)
try to the value
Returns:
0 or application specific error code return by the validator
Parameters:
newValue - the new value to be taken

template void addListener(MyListenerObject& listener, void (MyListenerObject::* method)(MyValueType))
Add a listener. Client code looks like "makeListenerCallback(*this, &Class::method)".

It is the responsibility of the client code to ensure that the listener object continues to exist until either the property is destroyed, or the listener is removed by calling "delListener()".

Parameters:
listener - object requiring notification
method - function to call for notification

the method prototype must:

  • be compatable with void (Class::* method)(Value new)
  • must not throw an exception

template void delListener(MyListenerObject& listener, void (MyListenerObject::* method)(MyValueType))
Delete a listener
Parameters:
listener - object no longer requiring notification
method - function called for notification

MyValueType value

MyValidator validator

std::list listeners


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de