34#ifndef CARTOBASE_OBJECT_OBJECT_D_H
35#define CARTOBASE_OBJECT_OBJECT_D_H
39#define INSTANTIATE_GENERIC_OBJECT_TYPE( T ) \
40 template class carto::TypedObject< T >; \
41 template class carto::ValueObject< T >; \
42 template class carto::ReferenceObject< T >; \
43 template class carto::PointerObject< T >; \
45 T const &GenericObject::value< T >() const; \
47 T &GenericObject::value< T >(); \
49 bool GenericObject::value( T &dest ) const; \
51 void GenericObject::setValue( T const & x ); \
53 void DictionaryInterface::setProperty( const std::string &key, \
56 this->setProperty( key, Object::value( value ) ); \
59 bool DictionaryInterface::getProperty( const std::string &key, T &value ) const \
62 if( getProperty( key, o ) && o.get() ) \
66 value = o->GenericObject::value< T >(); \
130 throw std::invalid_argument( std::string(
"cannot convert object from " )
132 +
" (dynamic cast failed from "
133 +
typeid(*this).name() +
" to "
134 +
typeid(u).name() +
")" );
144 throw std::invalid_argument( std::string(
"cannot convert object from " )
146 +
" (dynamic cast failed from "
147 +
typeid(*this).name() +
" to "
148 +
typeid(u).name() +
")" );
173 throw std::invalid_argument( std::string(
"cannot write value of type " )
175 +
" to object of type " +
type() );
225Interface *TypedObject<T>::_getGenericInterface()
227 return interface_internal::
234const void *TypedObject<T>::_getAddressOfValue()
const
243 throw std::runtime_error(
"pure virtual function called" );
251 throw std::runtime_error(
"pure virtual function called" );
264bool PrintInstantiation<T>::doIt(
bool *address )
267 std::cerr <<
"!instantiation! " <<
typeid(T).name() <<
" "
277bool PrintInstantiation<const T>::doIt(
bool *address)
280 std::cerr <<
"!instantiation! " <<
typeid(T).name() <<
" "
282 <<
static_cast<void *
>( address ) <<
" "
300 return interface_internal::
309 return interface_internal::
318 return interface_internal::
332 return interface_internal::
341 return interface_internal::
350 return interface_internal::
364 return interface_internal::
373 return interface_internal::
381 return interface_internal::
389 return interface_internal::
391 getArrayItem( *
this, index );
401 setArrayItem( *
this, index,
value );
414 return interface_internal::
425 reserveArray( *
this,
size );
435 resizeArray( *
this,
size );
445 removeArrayItem( *
this, index );
455 insertArrayItem( *
this, index, value );
483 return interface_internal::
494 return interface_internal::
496 getProperty( *
this,
key, result );
506 setProperty( *
this, key, value );
514 return interface_internal::
516 removeProperty( *
this,
key );
526 clearProperties( *
this );
534 return interface_internal::
536 hasProperty( *
this,
key );
549 return interface_internal::
558 return interface_internal::
560 objectIterator( *
this );
573 return interface_internal::
582 return interface_internal::
592 return interface_internal::
594 currentValue( *
this );
617 return interface_internal::
627 return interface_internal::
642 return interface_internal::
644 ::isDictionaryIterator( *
this );
652 return interface_internal::
667 return interface_internal::
677 return interface_internal::
692 return interface_internal::
705 return interface_internal::
707 ::equals( *
this, other );
709 return interface_internal::
711 ::equals( *
this, other );
713 return interface_internal::
715 ::equals( *
this, other );
717 return interface_internal::
719 ::equals( *
this, other );
804 : _pvalue( &x ), _owner( owner )
812 if ( _owner )
delete _pvalue;
ArrayInterface represents any container whose elements can be accessed via an integer index.
static std::string name()
Interface for dictionary-like objects.
Specialized IteratorInterface for dictionaries.
A dynamic array has resize and insertion capabilities (like a STL vector)
base abstract generic object class.
const T & value() const
Retrieve value in object, const reference.
void setValue(const T &val)
Store value in object by copying it.
virtual std::string type() const =0
type() returns the DataTypeCode::name() of the underlying object type
Specialized IteratorInterface for dictionaries.
Container objects which can be iterated.
An iterator object is a reference to another object.
Specialized IteratorInterface for key/value storage.
Specialized NoneInterface for empty objects (null, None).
static Object reference(T &value)
factory function: builds an Object by referencing the value from a ReferenceObject storage wrapper.
static Object value()
factory function: builds an Object by using the default constructor
PointerObject(T &x, bool owner)
virtual Object clone() const
cloning copy
virtual Object clone() const
cloning copy
virtual ~ReferenceObject()
All scalar numbers implement the ScalarInterface (all ints, float, double...)
All container objects inherit the SizeInterface.
Objects whose value may be represented as a character string.
storage wrapper, derived but still abstract template class
virtual long intKey() const
Access the key of the current dictionary element.
virtual bool isContiguous() const
Tells if array indices are contiguous (as in a vector), contrarily to an int key dictionary.
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
virtual bool isKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual Object keyObject() const
Access the key of the current element.
virtual Object clone() const
cloning copy
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
virtual void setValue(Object val)
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
virtual void insertArrayItem(int, Object)
inserts an element into the array.
virtual void removeArrayItem(int)
removes an element from the array.
virtual void setScalar(double)
The double value will be converted to the actual storage type before it is set in the contained objec...
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
virtual Object getArrayItem(int index) const
Get the element of index index.
virtual std::string key() const
Access the key of the current dictionary element.
virtual bool isIntKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual std::string getString() const
Obtain a string value, possibly after a conversion.
virtual void clearProperties()
clear the dictionary
virtual void reserveArray(size_t)
like the STL vector::reserve(), memory is reserved but no element is stored
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual bool getProperty(const std::string &, Object &) const
Access the element ok key key.
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
virtual void resizeArray(size_t)
resize the array.
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...
virtual bool isArray() const
Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since al...
virtual size_t size() const
Number of sub-elements.
virtual bool removeProperty(const std::string &)
remove an element.
virtual bool operator==(const GenericObject &other) const
virtual void setProperty(const std::string &, Object)
Set (insert or replace) the element of key key with the value object.
virtual bool hasItem(int index) const
Tells if array item index actually exists.
virtual bool hasProperty(const std::string &) const
check if an element exists under the key key
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
virtual double getScalar() const
Obtain a scalar value, possibly after a conversion.
virtual bool isValid() const
true if the iterator points to a valid value, false when the end of the iterable container has been r...
virtual void next()
Point to the next element of the iterable container.
virtual std::string type() const
type() returns the DataTypeCode::name() of the underlying object type
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
virtual bool isNone() const
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
virtual void setArrayItem(int, Object)
virtual Object clone() const
cloning copy
static bool isDictionary(const TypedObject< T > &object)
#define SUPERSUBCLASS(T, U)
void object_to(Object o, T &r)
static void check(T *x=NULL)