cartobase  5.0.5
carto::GenericObject Class Referenceabstract

base abstract generic object class. More...

#include <cartobase/object/object.h>

Inheritance diagram for carto::GenericObject:
Collaboration diagram for carto::GenericObject:

Public Member Functions

virtual ~GenericObject ()
 
virtual Object clone () const =0
 cloning copy More...
 
virtual std::string type () const =0
 type() returns the DataTypeCode::name() of the underlying object type More...
 
template<typename T >
const T & value () const
 Retreive value in object, const reference. More...
 
template<typename T >
T & value ()
 Retreive value in object, by non-const reference. More...
 
template<typename T >
bool value (T &) const
 Retreive 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...
 
virtual void setValue (Object val)=0
 
virtual size_t size () const =0
 Number of sub-elements. 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
 
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 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 =0
 Obtain a string value, possibly after a conversion. More...
 
virtual void setString (const std::string &)=0
 The string value may be converted to the actual storage type before it is set in the contained object. More...
 
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 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 =0
 Obtain a scalar value, possibly after a conversion. More...
 
virtual void setScalar (double)=0
 The double value will be converted to the actual storage type before it is set in the contained object. More...
 
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 ()
 
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)=0
 like the STL vector::reserve(), memory is reserved but no element is stored More...
 
virtual void resizeArray (size_t)=0
 resize the array. More...
 
virtual void removeArrayItem (int)=0
 removes an element from the array. More...
 
virtual void insertArrayItem (int, Object)=0
 inserts an element into the array. More...
 
- Public Member Functions inherited from carto::ArrayInterface
virtual ~ArrayInterface ()
 
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 Object getArrayItem (int index) const =0
 Get the element of index index. More...
 
virtual void setArrayItem (int, Object)=0
 
- Public Member Functions inherited from carto::SizeInterface
virtual ~SizeInterface ()
 
- 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 Object objectIterator () const =0
 returns an object implementing the IteratorIntrerface More...
 
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 ()
 
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 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...
 
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...
 
virtual bool removeProperty (const std::string &)=0
 remove an element. More...
 
virtual bool hasProperty (const std::string &key) const =0
 check if an element exists under the key key More...
 
virtual void clearProperties ()
 clear the dictionary 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 ()
 
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 =0
 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 =0
 Access the value of the element pointed to by the iterator. More...
 
virtual void next ()=0
 Point to the next element of the iterable container. More...
 
- Public Member Functions inherited from carto::KeyIteratorInterface
virtual ~KeyIteratorInterface ()
 
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 =0
 Access the key of the current element. More...
 
- Public Member Functions inherited from carto::DictionaryIteratorInterface
virtual ~DictionaryIteratorInterface ()
 
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 =0
 Access the key of the current dictionary element. More...
 
- Public Member Functions inherited from carto::IntKeyIteratorInterface
virtual ~IntKeyIteratorInterface ()
 
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 =0
 Access the key of the current dictionary element. More...
 
- Public Member Functions inherited from carto::NoneInterface
virtual ~NoneInterface ()
 
virtual bool isNone () const =0
 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...
 

Protected Member Functions

virtual Interface_getGenericInterface ()=0
 
virtual const void * _getAddressOfValue () const =0
 

Friends

class Object
 

Additional Inherited Members

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

Detailed Description

base abstract generic object class.

GenericObject holds the generic objects API, but functionalities are all implemented in subclasses (ValueObject or ReferenceObject).

GenericObject is normally used through Object, a reference counting pointer to a generic object. See Object for the documentation.

Definition at line 524 of file object.h.

Constructor & Destructor Documentation

◆ ~GenericObject()

virtual carto::GenericObject::~GenericObject ( )
virtual

Member Function Documentation

◆ _getAddressOfValue()

virtual const void* carto::GenericObject::_getAddressOfValue ( ) const
protectedpure virtual

◆ _getGenericInterface()

virtual Interface* carto::GenericObject::_getGenericInterface ( )
protectedpure virtual

◆ clone()

◆ getInterface() [1/2]

template<class T >
T * carto::GenericObject::getInterface ( )
inline

Obtain a specific Interface subclass.

GenericObject inherits all "standard" interfaces, but may hold an object which implements additional custom interfaces. getInterface() provides access to such additional interfaces.

Moreover an interface may be implemented either in the stored object itself if it inherits the interface, or in the container GenericObject, so getInterface() may return a pointer to either object.

In case of failure (interface not implemented), getInterface() returns 0 (null pointer).

As GenericObject inherits all standard interfaces but doesn't necessarily really implement them, there is still an ambiguity for them. Up to now, getInterface() returns a non-null pointer, and functions are provided in each standard interface to check if it is actually implemented or not (ScalarInterface::isScalar() for instance). In a future release, this function may return a null pointer.

Definition at line 1381 of file object.h.

◆ getInterface() [2/2]

template<class T >
const T * carto::GenericObject::getInterface ( ) const
inline

const access to an interface

Definition at line 1388 of file object.h.

◆ operator!=()

virtual bool carto::GenericObject::operator!= ( const GenericObject other) const
inlinevirtual

Definition at line 590 of file object.h.

References operator==().

◆ operator==()

virtual bool carto::GenericObject::operator== ( const GenericObject other) const
virtual

◆ setValue() [1/2]

template<typename T >
void carto::GenericObject::setValue ( const T &  val)

Store value in object by copying it.

This function only works if type T matches the actual value type stored in the object, otherwise it throws an exception

Definition at line 167 of file object_d.h.

Referenced by carto::GenericObjectTypeDeclared< Object >::check().

◆ setValue() [2/2]

virtual void carto::GenericObject::setValue ( Object  val)
pure virtual

◆ size()

virtual size_t carto::GenericObject::size ( ) const
pure virtual

Number of sub-elements.

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

Implements carto::SizeInterface.

Implemented in carto::TypedObject< T >, and carto::TypedObject< SyntaxedInterfaceType< T > >.

Referenced by carto::interface_internal::DictionaryImpl< T, true >::getProperty().

◆ type()

virtual std::string carto::GenericObject::type ( ) const
pure virtual

◆ value() [1/3]

template<typename T >
const T & carto::GenericObject::value ( ) const

Retreive value in object, const reference.

This function only works if type T matches the actual value type stored in the object, otherwise it throws an exception

Definition at line 126 of file object_d.h.

Referenced by carto::GenericObjectTypeDeclared< Object >::check().

◆ value() [2/3]

template<typename T >
T & carto::GenericObject::value ( )

Retreive value in object, by non-const reference.

This function only works if type T matches the actual value type stored in the object, otherwise it throws an exception

Definition at line 140 of file object_d.h.

References carto::TypedObject< T >::getValue(), and type().

◆ value() [3/3]

template<typename T >
bool carto::GenericObject::value ( T &  dest) const

Retreive value in object, and store it in a variable.

This function only works if type T matches the actual value type stored in the object, otherwise it throws an exception

Definition at line 154 of file object_d.h.

Friends And Related Function Documentation

◆ Object

friend class Object
friend

Definition at line 594 of file object.h.

Referenced by carto::PointerObject< T >::clone().


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