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() +
")" );
153 template <
typename T>
173 throw std::invalid_argument( std::string(
"cannot write value of type " )
175 +
" to object of type " +
type() );
185 template <
typename T>
193 template <
typename T>
200 template <
typename T>
208 template <
typename T>
224 template <
typename T>
233 template <
typename T>
240 template <
typename T>
243 throw std::runtime_error(
"pure virtual function called" );
248 template <
typename T>
251 throw std::runtime_error(
"pure virtual function called" );
257 template <
typename T>
259 PrintInstantiation<T>::doIt( &TypedObject<T>::_debugInstantiation );
263 template <
typename T>
264 bool PrintInstantiation<T>::doIt(
bool *address )
267 std::cerr <<
"!instantiation! " <<
typeid(T).name() <<
" " 276 template <
typename T>
277 bool PrintInstantiation<const T>::doIt(
bool *address)
280 std::cerr <<
"!instantiation! " <<
typeid(T).name() <<
" " 282 <<
static_cast<void *
>( address ) <<
" " 288 #endif // ifdef CARTO_DEBUG 297 template <
typename T>
306 template <
typename T>
315 template <
typename T>
329 template <
typename T>
338 template <
typename T>
347 template <
typename T>
361 template <
typename T>
370 template <
typename T>
373 return interface_internal::
374 ArrayImpl< T, SUPERSUBCLASS(ArrayInterface,T) >
:: 380 template <
typename T>
384 ArrayImpl< T, SUPERSUBCLASS(ArrayInterface,T) >
:: 395 template <
typename T>
404 template <
typename T>
408 DynArrayImpl< T, SUPERSUBCLASS(DynArrayInterface,T) >
:: 414 template <
typename T>
418 DynArrayImpl< T, SUPERSUBCLASS(DynArrayInterface,T) >
:: 424 template <
typename T>
428 DynArrayImpl< T, SUPERSUBCLASS(DynArrayInterface,T) >
:: 434 template <
typename T>
438 DynArrayImpl< T, SUPERSUBCLASS(DynArrayInterface,T) >
:: 450 template <
typename T>
464 template <
typename T>
467 return interface_internal::
468 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
474 template <
typename T>
478 return interface_internal::
479 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
:: 485 template <
typename T>
489 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
:: 495 template <
typename T>
498 return interface_internal::
499 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
:: 505 template <
typename T>
509 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
:: 515 template <
typename T>
518 return interface_internal::
519 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
:: 530 template <
typename T>
539 template <
typename T>
542 return interface_internal::
543 IterableImpl< T, SUPERSUBCLASS(IterableInterface,T) >
:: 554 template <
typename T>
563 template <
typename T>
566 return interface_internal::
567 IteratorImpl< T, SUPERSUBCLASS(IteratorInterface,T) >
:: 573 template <
typename T>
576 return interface_internal::
577 IteratorImpl< T, SUPERSUBCLASS(IteratorInterface,T) >
:: 583 template <
typename T>
587 IteratorImpl< T, SUPERSUBCLASS(IteratorInterface,T) >
:: 598 template <
typename T>
601 return interface_internal::
602 KeyIteratorImpl< T, SUPERSUBCLASS(KeyIteratorInterface,T) >
608 template <
typename T>
611 return interface_internal::
612 KeyIteratorImpl< T, SUPERSUBCLASS(KeyIteratorInterface,T) >
:: 623 template <
typename T>
626 return interface_internal::
627 DictionaryIteratorImpl< T, SUPERSUBCLASS(DictionaryIteratorInterface,T) >
633 template <
typename T>
636 return interface_internal::
637 DictionaryIteratorImpl< T, SUPERSUBCLASS(DictionaryIteratorInterface,T) >
:: 648 template <
typename T>
651 return interface_internal::
652 IntDictionaryIteratorImpl< T, SUPERSUBCLASS(IntKeyIteratorInterface,T) >
658 template <
typename T>
661 return interface_internal::
662 IntDictionaryIteratorImpl< T, SUPERSUBCLASS(IntKeyIteratorInterface,T) >
:: 673 template <
typename T>
676 return interface_internal::
677 NoneImpl< T, SUPERSUBCLASS(NoneInterface,T) >
683 template <
typename T>
689 return interface_internal::
690 ScalarImpl< T, SUPERSUBCLASS(ScalarInterface,T) >
691 ::equals( *
this, other );
693 return interface_internal::
694 StringImpl< T, SUPERSUBCLASS(StringInterface,T) >
695 ::equals( *
this, other );
697 return interface_internal::
698 DictionaryImpl< T, SUPERSUBCLASS(DictionaryInterface,T) >
699 ::equals( *
this, other );
701 return interface_internal::
702 IterableImpl< T, SUPERSUBCLASS(IterableInterface,T) >
703 ::equals( *
this, other );
713 template <
typename T>
719 template <
typename T>
726 template <
typename T>
733 template <
typename T>
741 template <
typename T>
753 template <
typename T>
760 template <
typename T>
767 template <
typename T>
774 template <
typename T>
786 template <
typename T>
788 : _pvalue( &x ), _owner( owner )
793 template <
typename T>
796 if ( _owner )
delete _pvalue;
801 template <
typename T>
808 template <
typename T>
817 #endif // ifndef CARTOBASE_OBJECT_OBJECT_D_H
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
virtual bool isKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual void setArrayItem(int, Object)=0
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
virtual bool getProperty(const std::string &key, Object &value) const =0
Access the element ok key key.
virtual bool getProperty(const std::string &, Object &) const
Access the element ok key key.
base abstract generic object class.
static void setString(TypedObject< T > &, const std::string &)
virtual Object getArrayItem(int index) const =0
Get the element of index index.
virtual bool isIntKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
static bool isDynArray(const TypedObject< T > &)
virtual bool isNone() const =0
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
virtual long intKey() const
Access the key of the current dictionary element.
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 void reserveArray(size_t)
like the STL vector::reserve(), memory is reserved but no element is stored
virtual void insertArrayItem(int, Object)=0
inserts an element into the array.
virtual Object clone() const
cloning copy
virtual void reserveArray(size_t)=0
like the STL vector::reserve(), memory is reserved but no element is stored
This class is just a hint to convert an actual data type to an identifier string used in input/output...
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
virtual void next()
Point to the next element of the iterable container.
virtual void clearProperties()
clear the dictionary
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual bool isIntKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual bool hasProperty(const std::string &key) const =0
check if an element exists under the key key
static void check(T *x=NULL)
static Object reference(T &value)
factory function: builds an Object by referencing the value from a ReferenceObject storage wrapper...
virtual Object keyObject() const =0
Access the key of the current element.
virtual long intKey() const =0
Access the key of the current dictionary element.
virtual bool isValid() const
true if the iterator points to a valid value, false when the end of the iterable container has been r...
static void setScalar(TypedObject< T > &, double)
virtual bool removeProperty(const std::string &)
remove an element.
virtual void insertArrayItem(int, Object)
inserts an element into the array.
static bool isIterable(const TypedObject< T > &)
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
static bool isIterator(const TypedObject< T > &)
static bool isString(const TypedObject< T > &)
storage wrapper, derived but still abstract template class
virtual void resizeArray(size_t)
resize the array.
virtual bool isNone() const
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
virtual bool isKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual void setScalar(double)
The double value will be converted to the actual storage type before it is set in the contained objec...
virtual std::string getString() const
Obtain a string value, possibly after a conversion.
void object_to(Object o, T &r)
virtual void resizeArray(size_t)=0
resize the array.
virtual Object clone() const
cloning copy
virtual size_t size() const
Number of sub-elements.
virtual void clearProperties()
clear the dictionary
static std::string name()
virtual bool operator==(const GenericObject &other) const
virtual void removeArrayItem(int)=0
removes an element from the array.
void setValue(const T &val)
Store value in object by copying it.
virtual Object objectIterator() const =0
returns an object implementing the IteratorIntrerface
virtual Object clone() const
cloning copy
static bool isScalar(const TypedObject< T > &)
virtual std::string type() const =0
type() returns the DataTypeCode::name() of the underlying object type
virtual void next()=0
Point to the next element of the iterable container.
virtual bool isArray() const
Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since al...
virtual Object getArrayItem(int index) const
Get the element of index index.
virtual void setProperty(const std::string &key, Object value)=0
Set (insert or replace) the element of key key with the value object.
static std::string getString(const TypedObject< T > &)
static Object value()
factory function: builds an Object by using the default constructor
virtual ~ReferenceObject()
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
virtual std::string key() const
Access the key of the current dictionary element.
const T & value() const
Retreive value in object, const reference.
virtual std::string type() const
type() returns the DataTypeCode::name() of the underlying object type
virtual Object currentValue() const =0
Access the value of the element pointed to by the iterator.
virtual void setValue(Object val)
static bool isArray(const TypedObject< T > &)
virtual void setProperty(const std::string &, Object)
Set (insert or replace) the element of key key with the value object.
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
virtual bool removeProperty(const std::string &)=0
remove an element.
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
virtual size_t size() const =0
Number of sub-elements.
virtual bool hasProperty(const std::string &) const
check if an element exists under the key key
static Interface * get(TypedObject< T > &)
virtual Object clone() const
cloning copy
virtual void removeArrayItem(int)
removes an element from the array.
static double getScalar(const TypedObject< T > &)
PointerObject(T &x, bool owner)
virtual bool isValid() const =0
true if the iterator points to a valid value, false when the end of the iterable container has been r...
virtual std::string key() const =0
Access the key of the current dictionary element.
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
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 Object keyObject() const
Access the key of the current element.
virtual void setArrayItem(int, Object)