|
Clipper
|
Class for holding a list of labelled properties of arbitrary types. More...
#include <clipper_memory.h>
Public Member Functions | |
| PropertyManager () | |
| null constructor | |
| PropertyManager (const PropertyManager &mgr) | |
| copy constructor | |
| PropertyManager & | operator= (const PropertyManager &mgr) |
| assign op | |
| ~PropertyManager () | |
| destructor | |
| PropertyManager & | copy (const PropertyManager &mgr) |
| copy manager | |
| bool | set_property (const std::string &label, const Property_base &property) |
| add a labelled property to the list | |
| const Property_base & | get_property (const std::string &label) const |
| get a labelled property from the list | |
| bool | exists_property (const std::string &label) const |
| test for property | |
| bool | delete_property (const std::string &label) |
| delete property | |
Class for holding a list of labelled properties of arbitrary types.
To add a property list to an object, derive it from this class, or include a member and mirror the methods. To add a property, simply call insert_property(label,property). Properties must be objects derived from clipper::Propert_base. Usually, you can just use the template form, clipper::Property<T>.
To read a property which you know exists and is of a particular type, use:
const T& obj = dynamic_cast<const Property<T>& >(list.get_property( label )).value();
If you are unsure if a property is present, use the exists_property(label) method. If you are unsure of a property's type, dynamic cast a pointer and test for null. e.g.
if ( !list.exists_property( label ) ) { error("No such property"); } const Property_base* ptr = &list.get_property( label ); if ( dynamic_cast<const T*>(ptr) == NULL ) { error("Wrong type"); } const T& obj = *(dynamic_cast<const T*>(ptr));
| clipper::PropertyManager::PropertyManager | ( | const PropertyManager & | mgr | ) |
| clipper::PropertyManager::~PropertyManager | ( | ) |
destructor
Deletes all stored properties.
| PropertyManager & clipper::PropertyManager::operator= | ( | const PropertyManager & | mgr | ) |
| PropertyManager & clipper::PropertyManager::copy | ( | const PropertyManager & | mgr | ) |
copy manager
This function is used by the copy constructor and assignement operator and is also useful for derived classes.
Referenced by operator=(), and PropertyManager().
| const Property_base & clipper::PropertyManager::get_property | ( | const std::string & | label | ) | const |
get a labelled property from the list
| label | The label of the property to be returned. |
References clipper::Message::message().
| bool clipper::PropertyManager::exists_property | ( | const std::string & | label | ) | const |
test for property
| label | The label of the property to be tested. |
1.7.4