cartobase  5.1.2
carto::TypedObject< T > Class Template Reference

storage wrapper, derived but still abstract template class More...

#include <cartobase/object/object.h>

Inheritance diagram for carto::TypedObject< T >:
Collaboration diagram for carto::TypedObject< T >:

Public Member Functions

 TypedObject ()
 
virtual ~TypedObject ()
 
virtual T & getValue ()
 
const T & getValue () const
 
virtual void setValue (Object val)
 
virtual Object clone () const
 cloning copy More...
 
virtual std::string type () const
 type() returns the DataTypeCode::name() of the underlying object type More...
 
virtual bool isScalar () const
 Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual double getScalar () const
 Obtain a scalar value, possibly after a conversion. More...
 
virtual void setScalar (double)
 The double value will be converted to the actual storage type before it is set in the contained object. More...
 
virtual bool isString () const
 Returns false if the stored object doesn't actually implement the StringInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual std::string getString () const
 Obtain a string value, possibly after a conversion. More...
 
virtual void setString (const std::string &)
 The string value may be converted to the actual storage type before it is set in the contained object. More...
 
virtual bool isArray () const
 Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual bool isContiguous () const
 Tells if array indices are contiguous (as in a vector), contrarily to an int key dictionary. More...
 
virtual bool hasItem (int index) const
 Tells if array item index actually exists. More...
 
virtual Object getArrayItem (int index) const
 Get the element of index index. More...
 
virtual void setArrayItem (int, Object)
 
virtual size_t size () const
 Number of sub-elements. More...
 
virtual bool isDynArray () const
 Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual void reserveArray (size_t)
 like the STL vector::reserve(), memory is reserved but no element is stored More...
 
virtual void resizeArray (size_t)
 resize the array. More...
 
virtual void removeArrayItem (int)
 removes an element from the array. More...
 
virtual void insertArrayItem (int, Object)
 inserts an element into the array. More...
 
virtual bool getProperty (const std::string &, Object &) const
 Access the element ok key key. More...
 
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...
 
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 &)
 remove an element. More...
 
virtual bool hasProperty (const std::string &) const
 check if an element exists under the key key More...
 
virtual void clearProperties ()
 clear the dictionary More...
 
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 Object objectIterator () const
 returns an object implementing the IteratorIntrerface More...
 
virtual bool isIterator () const
 Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual bool isValid () const
 true if the iterator points to a valid value, false when the end of the iterable container has been reached More...
 
virtual Object currentValue () const
 Access the value of the element pointed to by the iterator. More...
 
virtual void next ()
 Point to the next element of the iterable container. More...
 
virtual bool isKeyIterator () const
 Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual Object keyObject () const
 Access the key of the current element. More...
 
virtual bool isDictionaryIterator () const
 Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual std::string key () const
 Access the key of the current dictionary element. More...
 
virtual bool isIntKeyIterator () const
 Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual long intKey () const
 Access the key of the current dictionary element. More...
 
virtual bool isNone () const
 Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More...
 
virtual bool operator== (const GenericObject &other) const
 
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::GenericObject
virtual ~GenericObject ()
 
template<typename T >
const T & value () const
 Retrieve value in object, const reference. More...
 
template<typename T >
T & value ()
 Retrieve value in object, by non-const reference. More...
 
template<typename T >
bool value (T &) const
 Retrieve value in object, and store it in a variable. More...
 
template<typename T >
void setValue (const T &val)
 Store value in object by copying it. More...
 
template<typename T >
T * getInterface ()
 Obtain a specific Interface subclass. More...
 
template<typename T >
const T * getInterface () const
 const access to an interface More...
 
virtual bool operator!= (const GenericObject &other) const
 
- Public Member Functions inherited from carto::RCObject
 RCObject ()
 
 RCObject (const RCObject &)
 
RCObjectoperator= (const RCObject &)
 
virtual ~RCObject ()
 
- Public Member Functions inherited from carto::StringInterface
virtual ~StringInterface ()
 
virtual bool operator== (const StringInterface &other) const
 equality test More...
 
virtual bool operator!= (const StringInterface &other) const
 
- Public Member Functions inherited from carto::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from carto::ScalarInterface
virtual ~ScalarInterface ()
 
virtual bool operator== (const ScalarInterface &other) const
 equality test More...
 
virtual bool operator!= (const ScalarInterface &other) const
 
- Public Member Functions inherited from carto::DynArrayInterface
virtual ~DynArrayInterface ()
 
- Public Member Functions inherited from carto::ArrayInterface
virtual ~ArrayInterface ()
 
- Public Member Functions inherited from carto::SizeInterface
virtual ~SizeInterface ()
 
- Public Member Functions inherited from carto::IterableInterface
virtual ~IterableInterface ()
 
virtual bool operator== (const IterableInterface &other) const
 equality test More...
 
virtual bool operator!= (const IterableInterface &other) const
 
- Public Member Functions inherited from carto::DictionaryInterface
virtual ~DictionaryInterface ()
 
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::IteratorInterface
virtual ~IteratorInterface ()
 
- Public Member Functions inherited from carto::KeyIteratorInterface
virtual ~KeyIteratorInterface ()
 
- Public Member Functions inherited from carto::DictionaryIteratorInterface
virtual ~DictionaryIteratorInterface ()
 
- Public Member Functions inherited from carto::IntKeyIteratorInterface
virtual ~IntKeyIteratorInterface ()
 
- Public Member Functions inherited from carto::NoneInterface
virtual ~NoneInterface ()
 

Additional Inherited Members

- Public Types inherited from carto::RCObject
typedef int RefCounterType
 

Detailed Description

template<typename T>
class carto::TypedObject< T >

storage wrapper, derived but still abstract template class

TypedObject represents any kind of Generic object, but is still an abstract template class. See ValueObject and ReferenceObject for instanciable classes.

Definition at line 670 of file object.h.

Constructor & Destructor Documentation

◆ TypedObject()

template<typename T >
carto::TypedObject< T >::TypedObject

Definition at line 186 of file object_d.h.

References carto::GenericObjectTypeDeclared< T >::check().

◆ ~TypedObject()

template<typename T >
carto::TypedObject< T >::~TypedObject
virtual

Definition at line 194 of file object_d.h.

Member Function Documentation

◆ clearProperties()

template<typename T >
void carto::TypedObject< T >::clearProperties ( )
virtual

clear the dictionary

Reimplemented from carto::DictionaryInterface.

Definition at line 522 of file object_d.h.

References SUPERSUBCLASS.

◆ clone()

template<typename T >
Object carto::TypedObject< T >::clone ( ) const
virtual

◆ currentValue()

template<typename T >
Object carto::TypedObject< T >::currentValue ( ) const
virtual

Access the value of the element pointed to by the iterator.

Implements carto::IteratorInterface.

Definition at line 590 of file object_d.h.

References SUPERSUBCLASS.

◆ getArrayItem()

template<typename T >
Object carto::TypedObject< T >::getArrayItem ( int  index) const
virtual

Get the element of index index.

An exception will be thrown if the stored object doesn't actually implement the ArrayInterface. But if it does, access to an element of index greater or equal to size() should not be attempted: depending on the exact storage type and array implementation, it can either throw an exception, or simply crash the program.

Implements carto::ArrayInterface.

Definition at line 387 of file object_d.h.

References SUPERSUBCLASS.

◆ getProperty() [1/6]

template<typename T >
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/6]

template<typename T >
bool carto::TypedObject< T >::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.

Definition at line 491 of file object_d.h.

References SUPERSUBCLASS.

◆ getProperty() [3/6]

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

◆ getProperty() [4/6]

template<typename T >
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() [5/6]

template<typename T >
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() [6/6]

template<typename T >
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.

◆ getScalar()

template<typename T >
double carto::TypedObject< T >::getScalar ( ) const
virtual

Obtain a scalar value, possibly after a conversion.

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

Implements carto::ScalarInterface.

Definition at line 307 of file object_d.h.

References SUPERSUBCLASS.

◆ getString()

template<typename T >
std::string carto::TypedObject< T >::getString ( ) const
virtual

Obtain a string value, possibly after a conversion.

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

Implements carto::StringInterface.

Definition at line 339 of file object_d.h.

References SUPERSUBCLASS.

◆ getValue() [1/2]

◆ getValue() [2/2]

template<typename T >
const T & carto::TypedObject< T >::getValue
inline

Definition at line 201 of file object_d.h.

References carto::TypedObject< T >::getValue().

◆ hasItem()

template<typename T >
bool carto::TypedObject< T >::hasItem ( int  index) const
virtual

Tells if array item index actually exists.

False if index exceeds a vector size, or if it is not part of a dict key, for example.

Implements carto::ArrayInterface.

Definition at line 379 of file object_d.h.

References SUPERSUBCLASS.

◆ hasProperty()

template<typename T >
bool carto::TypedObject< T >::hasProperty ( const std::string &  key) const
virtual

check if an element exists under the key key

Implements carto::DictionaryInterface.

Definition at line 532 of file object_d.h.

References SUPERSUBCLASS.

◆ insertArrayItem()

template<typename T >
void carto::TypedObject< T >::insertArrayItem ( int  ,
Object   
)
virtual

inserts an element into the array.

All elements after this one may be moved, so iterators pointing after it may become invalid

Implements carto::DynArrayInterface.

Definition at line 451 of file object_d.h.

References SUPERSUBCLASS.

◆ intKey()

template<typename T >
long carto::TypedObject< T >::intKey ( ) const
virtual

Access the key of the current dictionary element.

Implements carto::IntKeyIteratorInterface.

Definition at line 675 of file object_d.h.

References SUPERSUBCLASS.

◆ isArray()

template<typename T >
bool carto::TypedObject< T >::isArray ( ) const
virtual

Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::ArrayInterface.

Definition at line 362 of file object_d.h.

References SUPERSUBCLASS.

◆ isContiguous()

template<typename T >
bool carto::TypedObject< T >::isContiguous ( ) const
virtual

Tells if array indices are contiguous (as in a vector), contrarily to an int key dictionary.

Implements carto::ArrayInterface.

Definition at line 371 of file object_d.h.

References SUPERSUBCLASS.

◆ isDictionary()

template<typename T >
bool carto::TypedObject< T >::isDictionary ( ) const
virtual

Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::DictionaryInterface.

Definition at line 481 of file object_d.h.

References SUPERSUBCLASS.

◆ isDictionaryIterator()

template<typename T >
bool carto::TypedObject< T >::isDictionaryIterator ( ) const
virtual

Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::DictionaryIteratorInterface.

Definition at line 640 of file object_d.h.

References SUPERSUBCLASS.

◆ isDynArray()

template<typename T >
bool carto::TypedObject< T >::isDynArray ( ) const
virtual

Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::DynArrayInterface.

Definition at line 412 of file object_d.h.

References SUPERSUBCLASS.

◆ isIntKeyIterator()

template<typename T >
bool carto::TypedObject< T >::isIntKeyIterator ( ) const
virtual

Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::IntKeyIteratorInterface.

Definition at line 665 of file object_d.h.

References SUPERSUBCLASS.

◆ isIterable()

template<typename T >
bool carto::TypedObject< T >::isIterable ( ) const
virtual

Returns false if the stored object doesn't actually implement the IterableInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::IterableInterface.

Definition at line 547 of file object_d.h.

References SUPERSUBCLASS.

◆ isIterator()

template<typename T >
bool carto::TypedObject< T >::isIterator ( ) const
virtual

Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::IteratorInterface.

Definition at line 571 of file object_d.h.

References SUPERSUBCLASS.

◆ isKeyIterator()

template<typename T >
bool carto::TypedObject< T >::isKeyIterator ( ) const
virtual

Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::KeyIteratorInterface.

Definition at line 615 of file object_d.h.

References SUPERSUBCLASS.

◆ isNone()

template<typename T >
bool carto::TypedObject< T >::isNone ( ) const
virtual

Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Implements carto::NoneInterface.

Definition at line 690 of file object_d.h.

References SUPERSUBCLASS.

◆ isScalar()

template<typename T >
bool carto::TypedObject< T >::isScalar ( ) const
virtual

Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::ScalarInterface.

Definition at line 298 of file object_d.h.

References SUPERSUBCLASS.

◆ isString()

template<typename T >
bool carto::TypedObject< T >::isString ( ) const
virtual

Returns false if the stored object doesn't actually implement the StringInterface API (needed since all GenericObject inherit this interface whatever they actually contain)

Reimplemented from carto::StringInterface.

Definition at line 330 of file object_d.h.

References SUPERSUBCLASS.

◆ isValid()

template<typename T >
bool carto::TypedObject< T >::isValid ( ) const
virtual

true if the iterator points to a valid value, false when the end of the iterable container has been reached

Implements carto::IteratorInterface.

Definition at line 580 of file object_d.h.

References SUPERSUBCLASS.

◆ key()

template<typename T >
std::string carto::TypedObject< T >::key ( ) const
virtual

Access the key of the current dictionary element.

Implements carto::DictionaryIteratorInterface.

Definition at line 650 of file object_d.h.

References SUPERSUBCLASS.

◆ keyObject()

template<typename T >
Object carto::TypedObject< T >::keyObject ( ) const
virtual

Access the key of the current element.

Implements carto::KeyIteratorInterface.

Definition at line 625 of file object_d.h.

References SUPERSUBCLASS.

◆ next()

template<typename T >
void carto::TypedObject< T >::next ( )
virtual

Point to the next element of the iterable container.

Implements carto::IteratorInterface.

Definition at line 600 of file object_d.h.

References SUPERSUBCLASS.

◆ objectIterator()

template<typename T >
Object carto::TypedObject< T >::objectIterator ( ) const
virtual

returns an object implementing the IteratorIntrerface

Implements carto::IterableInterface.

Definition at line 556 of file object_d.h.

References SUPERSUBCLASS.

◆ operator==()

template<typename T >
bool carto::TypedObject< T >::operator== ( const GenericObject other) const
virtual

Reimplemented from carto::GenericObject.

Definition at line 700 of file object_d.h.

References SUPERSUBCLASS.

◆ removeArrayItem()

template<typename T >
void carto::TypedObject< T >::removeArrayItem ( int  )
virtual

removes an element from the array.

All elements after the one removed may be moved, so iterators pointing after it may become invalid

Implements carto::DynArrayInterface.

Definition at line 441 of file object_d.h.

References SUPERSUBCLASS.

◆ removeProperty()

template<typename T >
bool carto::TypedObject< T >::removeProperty ( const std::string &  )
virtual

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 512 of file object_d.h.

References SUPERSUBCLASS.

◆ reserveArray()

template<typename T >
void carto::TypedObject< T >::reserveArray ( size_t  )
virtual

like the STL vector::reserve(), memory is reserved but no element is stored

Implements carto::DynArrayInterface.

Definition at line 421 of file object_d.h.

References SUPERSUBCLASS.

◆ resizeArray()

template<typename T >
void carto::TypedObject< T >::resizeArray ( size_t  )
virtual

resize the array.

This may need to copy all existing elements, so all iterators may become invalid after this operation

Implements carto::DynArrayInterface.

Definition at line 431 of file object_d.h.

References SUPERSUBCLASS.

◆ setArrayItem()

template<typename T >
void carto::TypedObject< T >::setArrayItem ( int  index,
Object  value 
)
virtual

Implements carto::ArrayInterface.

Definition at line 397 of file object_d.h.

References SUPERSUBCLASS.

◆ setProperty() [1/5]

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

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

◆ setProperty() [2/5]

template<typename T >
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() [3/5]

template<typename T >
void carto::TypedObject< T >::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.

Definition at line 502 of file object_d.h.

References SUPERSUBCLASS.

◆ setProperty() [4/5]

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

◆ setProperty() [5/5]

template<typename T >
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.

◆ setScalar()

template<typename T >
void carto::TypedObject< T >::setScalar ( double  )
virtual

The double value will be converted to the actual storage type before it is set in the contained object.

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

Implements carto::ScalarInterface.

Definition at line 316 of file object_d.h.

References SUPERSUBCLASS.

◆ setString()

template<typename T >
void carto::TypedObject< T >::setString ( const std::string &  )
virtual

The string value may be converted to the actual storage type before it is set in the contained object.

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

Implements carto::StringInterface.

Definition at line 348 of file object_d.h.

References SUPERSUBCLASS.

◆ setValue()

template<typename T >
void carto::TypedObject< T >::setValue ( Object  val)
virtual

Implements carto::GenericObject.

Definition at line 209 of file object_d.h.

References carto::object_to().

◆ size()

template<typename T >
size_t carto::TypedObject< T >::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::GenericObject.

Definition at line 467 of file object_d.h.

References SUPERSUBCLASS.

◆ type()

template<typename T >
std::string carto::TypedObject< T >::type ( ) const
virtual

type() returns the DataTypeCode::name() of the underlying object type

Implements carto::GenericObject.

Definition at line 217 of file object_d.h.

References carto::DataTypeCode< T >::name().


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