Clipper
Public Member Functions
clipper::PropertyManager Class Reference

Class for holding a list of labelled properties of arbitrary types. More...

#include <clipper_memory.h>

List of all members.

Public Member Functions

 PropertyManager ()
 null constructor
 PropertyManager (const PropertyManager &mgr)
 copy constructor
PropertyManageroperator= (const PropertyManager &mgr)
 assign op
 ~PropertyManager ()
 destructor
PropertyManagercopy (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_baseget_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

Detailed Description

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));

Constructor & Destructor Documentation

clipper::PropertyManager::PropertyManager ( const PropertyManager mgr)

copy constructor

Makes copies of all property objects.

References copy().

clipper::PropertyManager::~PropertyManager ( )

destructor

Deletes all stored properties.


Member Function Documentation

PropertyManager & clipper::PropertyManager::operator= ( const PropertyManager mgr)

assign op

Clears manager then makes copies of all property objects.

References copy().

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

Parameters:
labelThe label of the property to be returned.
Returns:
the property object.

References clipper::Message::message().

bool clipper::PropertyManager::exists_property ( const std::string &  label) const

test for property

Parameters:
labelThe label of the property to be tested.
Returns:
true on success.

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