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

Onyx::Properties::PropertyMap< T, CreateType > Class Template Reference

Class for managing maps of properties. More...

#include <PropertyMap.h>

Public Types

typedef PropertyMapAccessor< T > Accessor
 Typedef for the accessor.
typedef std::map< std::string,
std::vector< T * > > 
GroupPropertyTree
 Typedef used in conjunction with the getGroupTree member function.

Public Member Functions

void _handlePropertyChanged (const PropertyChangedEvent &event)
 Intenral method that intercepts PropertyChangedEvents and rerouts them to the propertyChangedEvent of PropertyMap.
void _handlePropertyValidationFailed (const PropertyValidationFailedEvent &event)
 Intenral method that intercepts PropertyChangedEvents and rerouts them to the propertyChangedEvent of PropertyMap.
T * addProperty (SimpleProperty &prop, const bool &persistent=false)
 Add a new Property to the PropertyMap (PropertyMap owns it).
T * addProperty (const std::string &name, const bool &persistent=false, const std::string &group="", const Poco::DynamicAny &value=0)
 Add a new Property to the PropertyMap (PropertyMap owns it).
void clearNonPersistentProperties ()
 This member function will remove all non-persistent Properties.
void disableValidators ()
 Disable validation on all Properties.
void enableValidators ()
 Enable validation on all Properties.
Accessor getAccessor ()
 Get the Accessor to the PropertyMap's Properties.
const bool & getAllowNewProperties ()
 Get whether or not the PropertyMap allows new Properties to be registered.
const std::string & getDefaultGroupName ()
 Get the default group name.
Accessor getGroup (const std::string &group="")
 Get all Properties with a specific group name.
std::set< std::string > getGroupNames ()
 Get a set containing the names of all Property groups in the PropertyMap.
GroupPropertyTree getPropertyTree ()
 Get a map of vectors of Property pointers organized by group.
bool hasProperty (const std::string &name)
 Get whether or not a Property has been registered with the PropertyMap.
bool hasProperty (T *const property)
 Get whether or not a Property has been registered with the PropertyMap.
bool isPersistent (const std::string &name)
 Get whether or not a Property is persistent.
bool isPersistent (T *const property)
 Get whether or not a Property is persistent.
T * operator[] (const std::string &name)
 Retrieve a Property using the index [] operator.
 PropertyMap (const std::string groupName="")
 Constrctor, defaults allowNewProperties to true.
 PropertyMap (const Onyx::Properties::PropertyMap< T, CreateType > &)
 Copy constructor needed for compiling reasons, doesn't do anything.
void registerProperty (T *property, bool persistent=false)
 Register a new Property with the PropertyMap.
void setAllowNewProperties (const bool &allows)
 Set whether or not the PropertyMap allows new Properties.
void setDefaultGroupName (const std::string &groupName)
 Set the default group name.
void unregisterProperty (T *property)
 Unregisters a non-persistent Property.
void unregisterProperty (const std::string &name)
 Unregisters a non-persistent Property.
virtual ~PropertyMap ()
 Destructor, deletes all Properties created by the Map itself.

Data Fields

Poco::BasicEvent< const
PropertyChangedEvent
propertyChangedEvent
 Event that is fired whenever a Property of the PropertyMap changes its value.
Poco::BasicEvent< const
PropertyValidationFailedEvent
propertyValidationFailedEvent
 Event that is fired whenever a Property of the PropertyMap fails validation.

Protected Attributes

bool allowNewProperties
 Boolean to determine whether or not new Properties can be registered.
std::string defaultGroupName
 Default group name to use when creating new properties with the [] operator.
std::map< std::string, T * > properties
 Map of Properties managed by the PropertyMap itself.
std::map< T *, bool > propertyPersistence
 Map of PropertyBase pointers used to keep track of which Properties are required.
std::map< std::string, T * > registeredProperties
 Map of registered Properties (Properties which are managed elsewhere).

Detailed Description

template<class T, class CreateType>
class Onyx::Properties::PropertyMap< T, CreateType >

Class for managing maps of properties.

Properties can be 'required', which means once they are registered they cannot be unregistered.

Parameters:
Base The base Property class, will usually be an abstract base class (PropertyBase, DefaultProperty, ClassProperty)
Warning:
This class does not take ownership of registered Properties (not those created using the [] operator though), so be very careful about scope.

Member Typedef Documentation

template<class T , class CreateType >
typedef PropertyMapAccessor<T> Onyx::Properties::PropertyMap< T, CreateType >::Accessor

Typedef for the accessor.

template<class T , class CreateType >
typedef std::map<std::string, std::vector<T*> > Onyx::Properties::PropertyMap< T, CreateType >::GroupPropertyTree

Typedef used in conjunction with the getGroupTree member function.


Constructor & Destructor Documentation

template<class T , class CreateType >
Onyx::Properties::PropertyMap< T, CreateType >::PropertyMap ( const Onyx::Properties::PropertyMap< T, CreateType > &   ) 

Copy constructor needed for compiling reasons, doesn't do anything.

template<class T , class CreateType >
Onyx::Properties::PropertyMap< T, CreateType >::PropertyMap ( const std::string  groupName = ""  ) 

Constrctor, defaults allowNewProperties to true.

Parameters:
groupName Default name to use when adding new Properties with the [] operator.
template<class T , class CreateType >
virtual Onyx::Properties::PropertyMap< T, CreateType >::~PropertyMap (  )  [virtual]

Destructor, deletes all Properties created by the Map itself.

References Onyx::Properties::PropertyMap< T, CreateType >::properties.


Member Function Documentation

template<class T , class CreateType >
const bool& Onyx::Properties::PropertyMap< T, CreateType >::getAllowNewProperties (  ) 

Get whether or not the PropertyMap allows new Properties to be registered.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::setAllowNewProperties ( const bool &  allows  ) 

Set whether or not the PropertyMap allows new Properties.

Parameters:
allows If true, the PropertyMap will allow new Properties to be registered.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties.

template<class T , class CreateType >
const std::string& Onyx::Properties::PropertyMap< T, CreateType >::getDefaultGroupName (  ) 
template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::setDefaultGroupName ( const std::string &  groupName  ) 

Set the default group name.

Parameters:
groupName New default group name to use.

References Onyx::Properties::PropertyMap< T, CreateType >::defaultGroupName.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::registerProperty ( T *  property,
bool  persistent = false 
)

Register a new Property with the PropertyMap.

Parameters:
property The Property to register.
persistent Whether or not the Property is persistent (cannot be unregistered, eg, is a class member).
Remarks:
This member function does not check if property is NULL. If there is already a Property named with Property's name or if allowNewProperties is false, an InvalidArgumentException will be thrown.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties, Onyx::Properties::PropertyMap< T, CreateType >::hasProperty(), Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
T* Onyx::Properties::PropertyMap< T, CreateType >::addProperty ( const std::string &  name,
const bool &  persistent = false,
const std::string &  group = "",
const Poco::DynamicAny &  value = 0 
)

Add a new Property to the PropertyMap (PropertyMap owns it).

Parameters:
name Name of the new Property.
persistent Whether or not the Property is persistent.
group Name of the group the Property belongs to.
value Value of the Property.
Remarks:
An InvalidArgumentException will be thrown if name is already in use or an allowNewProperties is false.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties, Onyx::Properties::PropertyMap< T, CreateType >::hasProperty(), Onyx::Properties::PropertyMap< T, CreateType >::properties, and Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence.

template<class T , class CreateType >
T* Onyx::Properties::PropertyMap< T, CreateType >::addProperty ( SimpleProperty prop,
const bool &  persistent = false 
)

Add a new Property to the PropertyMap (PropertyMap owns it).

Parameters:
prop Property to extract information from.
persistent Whther or not the added Property will be persistent.
Remarks:
An InvalidArgumentException will be thrown if name is already in use or an allowNewProperties is false.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties, Onyx::Properties::PropertyBase::get(), Onyx::Properties::PropertyBase::getGroup(), Onyx::Properties::PropertyBase::getName(), Onyx::Properties::PropertyMap< T, CreateType >::hasProperty(), Onyx::Properties::PropertyMap< T, CreateType >::properties, and Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::unregisterProperty ( const std::string &  name  ) 

Unregisters a non-persistent Property.

Parameters:
name Name of the Property to unregister.
Remarks:
An InvalidArgumentException will be thrown if there is no Property named name is registered or if the Property is persistent.

References Onyx::Properties::PropertyMap< T, CreateType >::properties, Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::unregisterProperty ( T *  property  ) 

Unregisters a non-persistent Property.

Parameters:
property Pointer to the Property to unregister.
Remarks:
An InvalidArgumentException will be thrown if there is no Property with property's name is registered or if the Property is persistent.

References Onyx::Properties::PropertyMap< T, CreateType >::properties, Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::clearNonPersistentProperties (  ) 
template<class T , class CreateType >
T* Onyx::Properties::PropertyMap< T, CreateType >::operator[] ( const std::string &  name  ) 

Retrieve a Property using the index [] operator.

Parameters:
name Name of the Property to retrieve.
Remarks:
An NotFoundException will be thrown if no Property named name has been registered and allowNewProperties is false. If it is true, a new Property named name and with default group name and value will be returned.

References Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties, Onyx::Properties::PropertyMap< T, CreateType >::defaultGroupName, Onyx::Properties::PropertyMap< T, CreateType >::properties, Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
Accessor Onyx::Properties::PropertyMap< T, CreateType >::getGroup ( const std::string &  group = ""  ) 

Get all Properties with a specific group name.

Parameters:
group Name of the group to return, can be blank (no group name).

References Onyx::Properties::PropertyMap< T, CreateType >::properties, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
std::set<std::string> Onyx::Properties::PropertyMap< T, CreateType >::getGroupNames (  ) 
template<class T , class CreateType >
GroupPropertyTree Onyx::Properties::PropertyMap< T, CreateType >::getPropertyTree (  ) 
template<class T , class CreateType >
bool Onyx::Properties::PropertyMap< T, CreateType >::hasProperty ( const std::string &  name  ) 

Get whether or not a Property has been registered with the PropertyMap.

Parameters:
name Name of the Property to check.

References Onyx::Properties::PropertyMap< T, CreateType >::properties, and Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties.

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::enableValidators (  ) 
template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::disableValidators (  ) 
template<class T , class CreateType >
bool Onyx::Properties::PropertyMap< T, CreateType >::hasProperty ( T *const   property  ) 

Get whether or not a Property has been registered with the PropertyMap.

Parameters:
property SharedPtr to the Property to check.

References Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence.

template<class T , class CreateType >
bool Onyx::Properties::PropertyMap< T, CreateType >::isPersistent ( const std::string &  name  ) 

Get whether or not a Property is persistent.

Parameters:
name Name of the Property to check.

References Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence.

template<class T , class CreateType >
bool Onyx::Properties::PropertyMap< T, CreateType >::isPersistent ( T *const   property  ) 

Get whether or not a Property is persistent.

Parameters:
property SharedPtr to the Property to check for.

References Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence.

template<class T , class CreateType >
Accessor Onyx::Properties::PropertyMap< T, CreateType >::getAccessor (  ) 
template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::_handlePropertyChanged ( const PropertyChangedEvent event  ) 

Intenral method that intercepts PropertyChangedEvents and rerouts them to the propertyChangedEvent of PropertyMap.

Parameters:
event Originating event which is simply passed on.
Remarks:
This is an internal method that is public only because it needs to be accessed by PropertyBase and its subclasses, it should not be called directly.

References Onyx::Properties::PropertyMap< T, CreateType >::propertyChangedEvent, and Onyx::Utils::EventBase< EventSource, EventType >::source().

template<class T , class CreateType >
void Onyx::Properties::PropertyMap< T, CreateType >::_handlePropertyValidationFailed ( const PropertyValidationFailedEvent event  ) 

Intenral method that intercepts PropertyChangedEvents and rerouts them to the propertyChangedEvent of PropertyMap.

Parameters:
event Originating event which is simply passed on.
Remarks:
This is an internal method that is public only because it needs to be accessed by PropertyBase and its subclasses, it should not be called directly.

References Onyx::Properties::PropertyMap< T, CreateType >::propertyValidationFailedEvent, and Onyx::Utils::EventBase< EventSource, EventType >::source().


Field Documentation

template<class T , class CreateType >
std::map<std::string, T*> Onyx::Properties::PropertyMap< T, CreateType >::registeredProperties [protected]

Map of registered Properties (Properties which are managed elsewhere).

template<class T , class CreateType >
std::map<std::string, T*> Onyx::Properties::PropertyMap< T, CreateType >::properties [protected]

Map of Properties managed by the PropertyMap itself.

template<class T , class CreateType >
std::map<T*, bool> Onyx::Properties::PropertyMap< T, CreateType >::propertyPersistence [protected]

Map of PropertyBase pointers used to keep track of which Properties are required.

template<class T , class CreateType >
bool Onyx::Properties::PropertyMap< T, CreateType >::allowNewProperties [protected]

Boolean to determine whether or not new Properties can be registered.

template<class T , class CreateType >
std::string Onyx::Properties::PropertyMap< T, CreateType >::defaultGroupName [protected]

Default group name to use when creating new properties with the [] operator.

template<class T , class CreateType >
Poco::BasicEvent<const PropertyChangedEvent> Onyx::Properties::PropertyMap< T, CreateType >::propertyChangedEvent

Event that is fired whenever a Property of the PropertyMap changes its value.

template<class T , class CreateType >
Poco::BasicEvent<const PropertyValidationFailedEvent> Onyx::Properties::PropertyMap< T, CreateType >::propertyValidationFailedEvent

Event that is fired whenever a Property of the PropertyMap fails validation.


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