#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 |
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 ( !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 | ) |
copy constructor
Makes copies of all property objects.
clipper::PropertyManager::~PropertyManager | ( | ) |
destructor
Deletes all stored properties.
PropertyManager & clipper::PropertyManager::operator= | ( | const PropertyManager & | mgr | ) |
assign op
Clears manager then makes copies of all property objects.
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.
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. |
bool clipper::PropertyManager::exists_property | ( | const std::string & | label | ) | const |
test for property
label | The label of the property to be tested. |