cartobase  5.1.2
carto::PropertySet Class Reference

A dictionary generic Object. More...

#include <cartobase/object/property.h>

Inheritance diagram for carto::PropertySet:
Collaboration diagram for carto::PropertySet:

Classes

class  iterator
 

Public Types

typedef ::sigc::signal3< void, const Object &, const std::string &, const Object & > Signal
 This signal type informs the slots about the sender (this), the property name and its old value. More...
 
- Public Types inherited from carto::RCObject
typedef int RefCounterType
 

Public Member Functions

 PropertySet ()
 
 PropertySet (const PropertySet &)
 
PropertySetoperator= (const PropertySet &)
 
virtual ~PropertySet ()
 
SignalgetSignalPropertyChanged ()
 
template<typename T >
void addBuiltinProperty (const std::string &, T &)
 
template<typename T >
void addBuiltinProperty (const std::string &, T &, bool &provided)
 add an optional builtin property More...
 
template<typename T >
bool getProperty (const std::string &, T &) const
 
template<typename T >
void setProperty (const std::string &, const T &)
 
virtual bool getProperty (const std::string &, Object &) const
 Access the element ok key key. More...
 
virtual void setProperty (const std::string &, Object)
 Set (insert or replace) the element of key key with the value object. More...
 
virtual bool removeProperty (const std::string &key)
 remove an element. More...
 
virtual bool hasProperty (const std::string &) const
 check if an element exists under the key key More...
 
virtual size_t size () const
 Number of sub-elements. More...
 
virtual void clearProperties ()
 clear the dictionary More...
 
virtual void copyBuiltinProperties (const PropertySet &source)
 
virtual Object objectIterator () const
 returns an object implementing the IteratorIntrerface More...
 
iterator getIterator () const
 
template<typename T >
void changeBuiltinProperty (const std::string &, T &)
 change the reference to a builtin property More...
 
template<typename T >
void changeBuiltinProperty (const std::string &, T &, bool &provided)
 change the reference to an optional builtin property More...
 
virtual bool getProperty (const std::string &key, Object &value) const=0
 Access the element ok key key. More...
 
Object getProperty (const std::string &) const
 same as the other getProperty() functions except that the value object is returned. More...
 
Object getProperty (Object key) const
 same as the other getProperty() functions except that the key is contained in the key argument (which must implement the StringInterface). More...
 
template<typename T >
bool getProperty (const std::string &key, T &value) const
 same as the other getProperty() functions except that the value object must be of exact type T and is copied to the value argument. More...
 
template<>
bool getProperty (const std::string &key, Object &value) const
 
virtual void setProperty (const std::string &key, Object value)=0
 Set (insert or replace) the element of key key with the value object. More...
 
void setProperty (const std::string &, const char *)
 specific specialization: C strings are stored as std::string objects More...
 
template<typename T >
void setProperty (const std::string &, const T &)
 same as the other setProperty() functions except that the value to be set is of the arbitrary type T and will possibly be stored in an Object. More...
 
template<>
void setProperty (const std::string &key, Object const &value)
 
- Public Member Functions inherited from carto::RCObject
 RCObject ()
 
 RCObject (const RCObject &)
 
RCObjectoperator= (const RCObject &)
 
virtual ~RCObject ()
 
- Public Member Functions inherited from carto::DictionaryInterface
virtual ~DictionaryInterface ()
 
virtual bool isDictionary () const
 Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
Object getProperty (const std::string &) const
 same as the other getProperty() functions except that the value object is returned. More...
 
Object getProperty (Object key) const
 same as the other getProperty() functions except that the key is contained in the key argument (which must implement the StringInterface). More...
 
template<typename T >
bool getProperty (const std::string &key, T &value) const
 same as the other getProperty() functions except that the value object must be of exact type T and is copied to the value argument. More...
 
void setProperty (const std::string &, const char *)
 specific specialization: C strings are stored as std::string objects More...
 
template<typename T >
void setProperty (const std::string &, const T &)
 same as the other setProperty() functions except that the value to be set is of the arbitrary type T and will possibly be stored in an Object. More...
 
virtual void copyProperties (Object source)
 copy all properties of the source object to this object. More...
 
virtual bool operator== (const DictionaryInterface &other) const
 equality test More...
 
virtual bool operator!= (const DictionaryInterface &other) const
 
template<>
void setProperty (const std::string &key, Object const &value)
 
template<>
bool getProperty (const std::string &key, Object &value) const
 
- Public Member Functions inherited from carto::SizeInterface
virtual ~SizeInterface ()
 
- Public Member Functions inherited from carto::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from carto::IterableInterface
virtual ~IterableInterface ()
 
virtual bool isIterable () const
 Returns false if the stored object doesn't actually implement the IterableInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual bool operator== (const IterableInterface &other) const
 equality test More...
 
virtual bool operator!= (const IterableInterface &other) const
 

Detailed Description

A dictionary generic Object.

PropertySet can replace a std::map<std::string,Object> in GenericObject implementations, and offers additional interesting features:

  • builtin properties support: a builtin property is a reference to an external existing variable (generally a member of a structure or class tied to the property set). They are used transparently just like any other dynamic properties, but as they use lower-level underlying variables, this allows optimizations in special cases when a program knows it operates on the exact intentded structure without breaking compatibility with the generic API. \ A builtin property can change value, but cannot change type because it references a typed value at a fixed memory location.
  • signal / slot support: signals are emitted whenever a property changes. The "raw" signal support is a low-level mechanism which fires every time any property changes. For a more convenient behaviour, a filter mechanism can be used in conjunction with Propertyset: PropertyFilter

Definition at line 75 of file property.h.

Member Typedef Documentation

◆ Signal

typedef ::sigc::signal3< void, const Object &, const std::string&, const Object& > carto::PropertySet::Signal

This signal type informs the slots about the sender (this), the property name and its old value.

Definition at line 82 of file property.h.

Constructor & Destructor Documentation

◆ PropertySet() [1/2]

carto::PropertySet::PropertySet ( )

◆ PropertySet() [2/2]

carto::PropertySet::PropertySet ( const PropertySet )

◆ ~PropertySet()

virtual carto::PropertySet::~PropertySet ( )
virtual

Member Function Documentation

◆ addBuiltinProperty() [1/2]

template<typename T >
void carto::PropertySet::addBuiltinProperty ( const std::string &  key,
T &  reference 
)

Definition at line 241 of file property.h.

References carto::Object::reference().

Referenced by changeBuiltinProperty().

◆ addBuiltinProperty() [2/2]

template<typename T >
void carto::PropertySet::addBuiltinProperty ( const std::string &  key,
T &  reference,
bool &  provided 
)

add an optional builtin property

Definition at line 255 of file property.h.

References carto::Object::reference().

◆ changeBuiltinProperty() [1/2]

template<typename T >
void carto::PropertySet::changeBuiltinProperty ( const std::string &  key,
T &  reference 
)

change the reference to a builtin property

Definition at line 270 of file property.h.

References addBuiltinProperty().

◆ changeBuiltinProperty() [2/2]

template<typename T >
void carto::PropertySet::changeBuiltinProperty ( const std::string &  key,
T &  reference,
bool &  provided 
)

change the reference to an optional builtin property

Definition at line 285 of file property.h.

References addBuiltinProperty().

◆ clearProperties()

virtual void carto::PropertySet::clearProperties ( )
virtual

clear the dictionary

Reimplemented from carto::DictionaryInterface.

◆ copyBuiltinProperties()

virtual void carto::PropertySet::copyBuiltinProperties ( const PropertySet source)
virtual

◆ getIterator()

PropertySet::iterator carto::PropertySet::getIterator ( ) const
inline

Definition at line 314 of file property.h.

◆ getProperty() [1/7]

Object carto::DictionaryInterface::getProperty

same as the other getProperty() functions except that the value object is returned.

An exception is thrown in case of failure.

◆ getProperty() [2/7]

virtual bool carto::PropertySet::getProperty ( const std::string &  key,
Object value 
) const
virtual

Access the element ok key key.

value is filled with a wrapper to the selected element. If it fails (key not found for instance), an exception is thrown.

Implements carto::DictionaryInterface.

◆ getProperty() [3/7]

template<typename T >
bool carto::PropertySet::getProperty ( const std::string &  key,
T &  value 
) const

Definition at line 301 of file property.h.

◆ getProperty() [4/7]

template<>
bool carto::DictionaryInterface::getProperty ( )

◆ getProperty() [5/7]

virtual bool carto::DictionaryInterface::getProperty

Access the element ok key key.

value is filled with a wrapper to the selected element. If it fails (key not found for instance), an exception is thrown.

◆ getProperty() [6/7]

template<typename T >
bool carto::DictionaryInterface::getProperty ( typename T  )

same as the other getProperty() functions except that the value object must be of exact type T and is copied to the value argument.

No exception is thrown if the key is not found or the selected element is not of type T, but the return value is false if it fails. An exception is still thrown if this function is called on an object that doesn't actually implement the DictionaryInterface API.

Definition at line 445 of file object.h.

◆ getProperty() [7/7]

Object carto::DictionaryInterface::getProperty

same as the other getProperty() functions except that the key is contained in the key argument (which must implement the StringInterface).

The value object is returned. An exception is thrown in case of failure.

◆ getSignalPropertyChanged()

Signal& carto::PropertySet::getSignalPropertyChanged ( )

◆ hasProperty()

virtual bool carto::PropertySet::hasProperty ( const std::string &  key) const
virtual

check if an element exists under the key key

Implements carto::DictionaryInterface.

◆ objectIterator()

virtual Object carto::PropertySet::objectIterator ( ) const
virtual

returns an object implementing the IteratorIntrerface

Implements carto::IterableInterface.

◆ operator=()

PropertySet& carto::PropertySet::operator= ( const PropertySet )

◆ removeProperty()

virtual bool carto::PropertySet::removeProperty ( const std::string &  )
inlinevirtual

remove an element.

Note that on some dictionary implementations (PropertySet with builtin properties for instance), some properties cannot be removed.

Implements carto::DictionaryInterface.

Definition at line 104 of file property.h.

◆ setProperty() [1/6]

void carto::DictionaryInterface::setProperty

specific specialization: C strings are stored as std::string objects

◆ setProperty() [2/6]

template<typename T >
void carto::PropertySet::setProperty ( const std::string &  key,
const T &  value 
)

Definition at line 211 of file property.h.

References carto::Object::reference(), and carto::Object::value().

◆ setProperty() [3/6]

template<typename T >
void carto::DictionaryInterface::setProperty ( typename T  )

same as the other setProperty() functions except that the value to be set is of the arbitrary type T and will possibly be stored in an Object.

The same type restrictions apply as for the other setProperty() functions

Definition at line 462 of file object.h.

◆ setProperty() [4/6]

virtual void carto::PropertySet::setProperty ( const std::string &  key,
Object  value 
)
virtual

Set (insert or replace) the element of key key with the value object.

On some specific dictionary implementations (such as PropertySet with builtin properties, or maps of specific, typed values), an existing property cannot change type. In this case value must hold an object of the correct type, otherwise an exception will be thrown.

Implements carto::DictionaryInterface.

◆ setProperty() [5/6]

template<>
void carto::DictionaryInterface::setProperty ( )

◆ setProperty() [6/6]

virtual void carto::DictionaryInterface::setProperty

Set (insert or replace) the element of key key with the value object.

On some specific dictionary implementations (such as PropertySet with builtin properties, or maps of specific, typed values), an existing property cannot change type. In this case value must hold an object of the correct type, otherwise an exception will be thrown.

◆ size()

virtual size_t carto::PropertySet::size ( ) const
virtual

Number of sub-elements.

This method may throw an exception if the stored object has not a size-compatible interface

Implements carto::SizeInterface.


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