cartobase  5.1.2
object.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef CARTOBASE_OBJECT_OBJECT_H
35 #define CARTOBASE_OBJECT_OBJECT_H
36 
38 #include <cartobase/type/types.h>
41 #include <cartobase/smart/rcptr.h>
43 #include <stdexcept>
44 #include <string>
45 #include <set>
46 #include <vector>
47 #include <list>
48 #include <typeinfo>
49 #ifdef CARTO_DEBUG
51 #include <iostream>
52 #endif // #ifdef CARTO_DEBUG
54 
55 
56 #define DECLARE_GENERIC_OBJECT_TYPE( T ) \
57 template <> \
58 struct GenericObjectTypeDeclared< T > \
59 { \
60  static inline void check() {} \
61 }; \
62 template <> \
63 void DictionaryInterface::setProperty( const std::string &key, \
64  T const &value ); \
65 template <> \
66 bool DictionaryInterface::getProperty( const std::string &key, T &value ) const; \
67 extern template class TypedObject< T >; \
68 extern template class ValueObject< T >; \
69 extern template class ReferenceObject< T >; \
70 extern template class PointerObject< T >; \
71 extern template \
72 T const &GenericObject::value< T >() const; \
73 extern template \
74 T &GenericObject::value< T >(); \
75 extern template \
76 bool GenericObject::value( T &dest ) const; \
77 extern template \
78 void GenericObject::setValue( T const & x ); \
79 extern template bool DictionaryInterface:: \
80 getProperty( const std::string &, T & ) const; \
81 extern template void DictionaryInterface:: \
82 setProperty( const std::string &, T const & ); \
83 
84 
85 namespace carto
86 {
87 class GenericObject;
88 template <typename T> class TypedObject;
89 class Object;
90 
91 
92  //-------------//
93  // Interface //
94  //-------------//
95 
96  class Interface
97  {
98  public:
99  virtual ~Interface();
100  };
101 
102 
103  //-------------------//
104  // ScalarInterface //
105  //-------------------//
106 
109  class ScalarInterface : public virtual Interface
110  {
111  public:
112 
113  virtual ~ScalarInterface();
114 
119  virtual bool isScalar() const;
124  virtual double getScalar() const = 0;
130  virtual void setScalar( double ) = 0;
132  virtual bool operator == ( const ScalarInterface & other ) const;
133  virtual bool operator != ( const ScalarInterface & other ) const
134  { return ! operator == ( other ); }
135  };
136 
137 
138  //-------------------//
139  // StringInterface //
140  //-------------------//
141 
143  class StringInterface : public virtual Interface
144  {
145  public:
146 
147  virtual ~StringInterface();
148 
153  virtual bool isString() const;
158  virtual std::string getString() const = 0;
164  virtual void setString( const std::string & ) = 0;
166  virtual bool operator == ( const StringInterface & other ) const;
167  virtual bool operator != ( const StringInterface & other ) const
168  { return ! operator == ( other ); }
169  };
170 
171 
172  //------------------//
173  // SizeInterface //
174  //------------------//
175 
177  class SizeInterface : public virtual Interface
178  {
179  public:
180 
181  virtual ~SizeInterface();
182 
187  virtual size_t size() const = 0;
188  };
189 
190 
191  //----------------------//
192  // IterableInterface //
193  //----------------------//
194 
196  class IterableInterface : public virtual Interface
197  {
198  public:
199 
201 
206  virtual bool isIterable() const;
208  virtual Object objectIterator() const = 0;
210  virtual bool operator == ( const IterableInterface & other ) const;
211  virtual bool operator != ( const IterableInterface & other ) const
212  { return ! operator == ( other ); }
213  };
214 
215 
216  //----------------------//
217  // IteratorInterface //
218  //----------------------//
219 
235  class IteratorInterface : public virtual Interface
236  {
237  public:
238 
240 
245  virtual bool isIterator() const;
248  virtual bool isValid() const = 0;
250  virtual Object currentValue() const = 0;
252  virtual void next() = 0;
253  };
254 
255 
256  //-------------------------//
257  // KeyIteratorInterface //
258  //-------------------------//
259 
265  {
266  public:
267 
269 
274  virtual bool isKeyIterator() const;
276  virtual Object keyObject() const = 0;
277  };
278 
279 
280  //--------------------------------//
281  // DictionaryIteratorInterface //
282  //--------------------------------//
283 
289  {
290  public:
291 
293 
298  virtual bool isDictionaryIterator() const;
300  virtual std::string key() const = 0;
301  };
302 
303 
304  //----------------------------//
305  // IntKeyIteratorInterface //
306  //----------------------------//
307 
313  {
314  public:
315 
317 
322  virtual bool isIntKeyIterator() const;
324  virtual long intKey() const = 0;
325  };
326 
327 
328  //------------------//
329  // ArrayInterface //
330  //------------------//
331 
334  class ArrayInterface : public virtual SizeInterface,
335  public virtual IterableInterface
336  {
337  public:
338 
339  virtual ~ArrayInterface();
340 
345  virtual bool isArray() const;
349  virtual bool isContiguous() const = 0;
354  virtual bool hasItem( int index ) const = 0;
362  virtual Object getArrayItem( int index ) const = 0;
363  virtual void setArrayItem( int, Object ) = 0;
364  virtual size_t size() const = 0;
365  };
366 
367 
368  //---------------------//
369  // DynArrayInterface //
370  //---------------------//
371 
373  class DynArrayInterface : public virtual ArrayInterface
374  {
375  public:
376 
378 
383  virtual bool isDynArray() const;
386  virtual void reserveArray( size_t ) = 0;
390  virtual void resizeArray( size_t ) = 0;
393  virtual void removeArrayItem( int ) = 0;
396  virtual void insertArrayItem( int, Object ) = 0;
397  };
398 
399 
400  //------------------------//
401  // DictionaryInterface //
402  //------------------------//
403 
412  class DictionaryInterface : public virtual SizeInterface,
413  public virtual IterableInterface
414  {
415  public:
416 
418 
423  virtual bool isDictionary() const;
428  virtual bool getProperty( const std::string & key,
429  Object & value ) const = 0;
432  Object getProperty( const std::string & ) const;
437  Object getProperty( Object key ) const;
445  template <typename T> bool getProperty( const std::string & key,
446  T & value ) const;
447 
455  virtual void setProperty( const std::string & key, Object value ) = 0;
457  void setProperty( const std::string &, const char * );
462  template <typename T> void setProperty( const std::string &, const T & );
463 
468  virtual bool removeProperty( const std::string & ) = 0;
469 
471  virtual bool hasProperty( const std::string & key ) const = 0;
473  virtual void clearProperties();
476  virtual void copyProperties( Object source );
478  virtual bool operator == ( const DictionaryInterface & other ) const;
479  virtual bool operator != ( const DictionaryInterface & other ) const
480  { return ! operator == ( other ); }
481  };
482 
483 
484  //----------------------//
485  // SyntaxedInterface //
486  //----------------------//
487 
493  class SyntaxedInterface : public virtual Interface
494  {
495  public:
496 
498 
499  virtual std::string getSyntax() const = 0;
500  virtual bool hasSyntax() const = 0;
501  virtual void setSyntax( const std::string& syntactic ) = 0;
503  virtual bool operator == ( const SyntaxedInterface & other ) const;
504  virtual bool operator != ( const SyntaxedInterface & other ) const
505  { return ! operator == ( other ); }
506  };
507 
508 
509  //------------------//
510  // NoneInterface //
511  //------------------//
512 
515  class NoneInterface : public virtual Interface
516  {
517  public:
518 
519  virtual ~NoneInterface();
520 
525  virtual bool isNone() const = 0;
526  };
527 
528 
529  //-----------------//
530  // GenericObject //
531 //-----------------//
532 
534  public virtual RCObject,
535  public virtual StringInterface,
536  public virtual ScalarInterface,
537  public virtual DynArrayInterface,
538  public virtual DictionaryInterface,
539  public virtual IterableInterface,
540  public virtual IteratorInterface,
541  public virtual KeyIteratorInterface,
542  public virtual DictionaryIteratorInterface,
543  public virtual IntKeyIteratorInterface,
544  public virtual NoneInterface
545 {
546 public:
547  virtual ~GenericObject();
548 
550  virtual Object clone() const = 0;
552  virtual std::string type() const = 0;
553 
557  template<typename T> const T & value() const;
561  template<typename T> T & value();
565  template <typename T> bool value( T & ) const;
569  template<typename T> void setValue( const T &val );
570  virtual void setValue( Object val ) = 0;
571 
572  virtual size_t size() const = 0;
573 
593  template <typename T>
594  T *getInterface();
596  template <typename T>
597  const T *getInterface() const;
598  virtual bool operator == ( const GenericObject & other ) const;
599  virtual bool operator != ( const GenericObject & other ) const
600  { return ! operator == ( other ); }
601 
602 protected:
603  friend class Object;
604 
606  virtual const void *_getAddressOfValue() const = 0;
607 };
608 
609 
610  //----------//
611  // Object //
612 //----------//
613 
614 class Object : public rc_ptr<GenericObject>
615 {
616 public:
617  Object();
618  Object( const Object & );
619  Object( GenericObject* data, bool externalowner = false );
620  virtual ~Object();
622  inline Object & operator = ( const Object & );
623 
625  template <typename T>
626  static inline Object value();
627 
630  template <typename T>
631  static inline Object value( const T & );
632 
637  template <typename T>
638  static inline Object reference( T & value );
639 
643  template <typename T>
644  static inline Object reference( const T & value );
645 
647  bool isSameObject( const Object & ) const;
658  bool isNone() const;
659  inline bool operator == ( const Object & other ) const;
660  inline bool operator != ( const Object & other ) const
661  { return ! operator == ( other ); }
662 };
663 
664 
665  //------------------//
666  // TypedObject<T> //
667 //------------------//
668 
669 template <typename T>
671 {
672 public:
673  TypedObject();
674  virtual ~TypedObject();
675 
676  // This function should be pure virtual but it is mandatory to
677  // do explicit instantiation of TypedObject and it is not possible
678  // with pure virtual classes.
679  virtual T &getValue();
680  inline const T &getValue() const;
681  virtual void setValue( Object val );
682 
683  // This function should be pure virtual but it is mandatory to
684  // do explicit instantiation of TypedObject and it is not possible
685  // with pure virtual classes.
686  virtual Object clone() const;
687 
688  virtual std::string type() const;
689 
690  // ScalarInterface methods
691  virtual bool isScalar() const;
692  virtual double getScalar() const;
693  virtual void setScalar( double );
694 
695  // StringInterface methods
696  virtual bool isString() const;
697  virtual std::string getString() const;
698  virtual void setString( const std::string & );
699 
700  // ArrayInterface methods
701  virtual bool isArray() const;
702  virtual bool isContiguous() const;
703  virtual bool hasItem( int index ) const;
704  virtual Object getArrayItem( int index ) const;
705  virtual void setArrayItem( int, Object );
706  virtual size_t size() const;
707 
708  // DynArrayInterface methods
709  virtual bool isDynArray() const;
710  virtual void reserveArray( size_t );
711  virtual void resizeArray( size_t );
712  virtual void removeArrayItem( int );
713  virtual void insertArrayItem( int, Object );
714 
715  // DictionaryInterface methods
716  virtual bool getProperty( const std::string &, Object & ) const;
717  virtual bool isDictionary() const;
719 
720  virtual void setProperty( const std::string &, Object );
722 
723  virtual bool removeProperty( const std::string & );
724  virtual bool hasProperty( const std::string & ) const;
725  virtual void clearProperties();
726 
727  // IterableInterface methods
728  virtual bool isIterable() const;
729  virtual Object objectIterator() const;
730 
731  // IteratorInterface methods
732  virtual bool isIterator() const;
733  virtual bool isValid() const;
734  virtual Object currentValue() const;
735  virtual void next();
736 
737  // KeyIteratorInterface methods
738  virtual bool isKeyIterator() const;
739  virtual Object keyObject() const;
740 
741  // DictionaryIteratorInterface methods
742  virtual bool isDictionaryIterator() const;
743  virtual std::string key() const;
744 
745  // IntKeyIteratorInterface methods
746  virtual bool isIntKeyIterator() const;
747  virtual long intKey() const;
748 
749  // NoneInterface methods
750  virtual bool isNone() const;
751 
752  virtual bool operator == ( const GenericObject & other ) const;
753 
754 private:
755  Interface *_getGenericInterface();
756  const void *_getAddressOfValue() const;
757 #ifdef CARTO_DEBUG
758  static bool _debugInstantiation;
759 #endif // ifdef CARTO_DEBUG
760 };
761 
762 
763 //-----------------------------------------------------------------------------
765 // is automatically instanitiated on a non declared type.
766 template <typename T>
768 {
769  static inline void check( T *x = NULL )
770  {
771  you_must_use_DECLARE_GENERIC_OBJECT_TYPE( x );
772  }
773 };
774 
775 
776 //-----------------------------------------------------------------------------
777 template <typename T>
778 class TypedObject<const T> : public GenericObject
779 {
780 private:
781  // Forbid TypedObject on constant type
782  TypedObject() {};
783 };
784 
785 
786 
787 #ifdef CARTO_DEBUG
788 template <typename T>
789 class PrintInstantiation
790 {
791 public:
792 
793  static bool doIt( bool * );
794 };
795 
796 
797 template <typename T>
798 class PrintInstantiation<const T>
799 {
800 public:
801 
802  static bool doIt( bool * );
803 };
804 #endif // ifdef CARTO_DEBUG
805 
806 
807 
808 
809  #if 0
810  //--------------------------//
811  // ForbidInheritance<T,U> //
812 //--------------------------//
813 template <typename T, bool B>
814 class CompileErrorIfFalse
815 {
816  static inline void check() {}
817 };
818 
819 template <typename T>
820 class CompileErrorIfFalse<T,false>
821 {
822  static inline void check()
823  {
824  T::cannot_compile_this_code();
825  }
826 };
827 
828 template <typename T, typename U>
829 class ForbidInheritance : CompileErrorIfFalse< T, SUPERSUBCLASS( T, U ) >
830 {
831 };
832 #endif
833 
834 
835  //------------------//
836  // ValueObject<T> //
837 //------------------//
838 
839 template <typename T>
840 class ValueObject : public TypedObject<T>
841 {
842 public:
843  ValueObject();
844  ValueObject( const T & x );
845  virtual ~ValueObject();
846 
847  virtual T &getValue();
848 
849  virtual Object clone() const;
850 
851 private:
852 
853  // class _Test : ForbidInheritance< GenericObject, T > {};
854  mutable T _value;
855 };
856 
857 
858  //-----------------------//
859  // Useful common types //
860 //-----------------------//
861 
866 typedef std::map<std::string, Object> Dictionary;
867 typedef std::map<int, Object> IntDictionary;
868 typedef std::map<Object, Object> ObjectDictionary;
870 typedef std::vector<Object> ObjectVector;
871 
872 
873  //----------------------//
874  // ReferenceObject<T> //
875 //----------------------//
876 
877 template <typename T>
878 class ReferenceObject : public TypedObject<T>
879 {
880 public:
881  ReferenceObject( T &x );
882  virtual ~ReferenceObject();
883  virtual T &getValue();
884 
885  virtual Object clone() const;
886 
887 private:
888 
889  // class _Test : ForbidInheritance< GenericObject, T > {};
890  T &_value;
891 };
892 
893 
894  //--------------------//
895  // PointerObject<T> //
896 //--------------------//
897 
898 template <typename T>
899 class PointerObject : public TypedObject<T>
900 {
901 public:
902  PointerObject( T &x, bool owner );
903  virtual ~PointerObject();
904  virtual T &getValue();
905 
906  virtual Object clone() const;
907 
908 private:
909 
910  mutable T *_pvalue;
911  bool _owner;
912 };
913 
914 
915  //--------//
916  // none //
917 //--------//
918 
920 extern Object none();
921 
922 
923  //----------------//
924  // object_to<T> //
925 //----------------//
926 
927 //-----------------------------------------------------------------------------
928 template <typename T>
929 inline void object_to( Object o, T & r );
930 
931 //-----------------------------------------------------------------------------
932 /* This specialization is a workaaround to avoid a bug in gcc 3.4.3 (at least).
933  This function needs to be compiled and I really really don't know why.
934  Otherwise it seems not to be called at all (hopefully)
935 */
936 template <typename T>
937 inline void object_to( Object, const T & );
938 
939 
940  //------------------//
941  // instantiations //
942 //------------------//
943 
945 DECLARE_GENERIC_OBJECT_TYPE( unsigned )
947 DECLARE_GENERIC_OBJECT_TYPE( signed char )
948 DECLARE_GENERIC_OBJECT_TYPE( unsigned char )
950 DECLARE_GENERIC_OBJECT_TYPE( unsigned short )
952 DECLARE_GENERIC_OBJECT_TYPE( unsigned long )
953 DECLARE_GENERIC_OBJECT_TYPE( long long )
954 DECLARE_GENERIC_OBJECT_TYPE( unsigned long long )
958 DECLARE_GENERIC_OBJECT_TYPE( std::string )
961 
962 // DECLARE_GENERIC_OBJECT_TYPE cannot be used for Object because it refers to
963 // extern explicit template instantiations of
964 // DictionaryInterface::getProperty<Object> and
965 // DictionaryInterface::setProperty<Object>, which conflict with the (pure
966 // virtual) overload of these methods.
967 template <>
969 {
970  static inline void check() {};
971 };
972 template <>
973 void DictionaryInterface::setProperty( const std::string &key,
974  Object const &value );
975 template <>
976 bool DictionaryInterface::getProperty( const std::string &key, Object &value ) const;
977 extern template class TypedObject< Object >;
978 extern template class ValueObject< Object >;
979 extern template class ReferenceObject< Object >;
980 extern template class PointerObject< Object >;
981 extern template
982 Object const &GenericObject::value< Object >() const;
983 extern template
984 Object &GenericObject::value< Object >();
985 extern template
986 bool GenericObject::value( Object &dest ) const;
987 extern template
988 void GenericObject::setValue( Object const & x );
989 
990 
991 template <>
993 {
994  static inline void check() {};
995 };
996 extern template class TypedObject< GenericObject >;
997 extern template class ReferenceObject< GenericObject >;
998 extern template class PointerObject< GenericObject >;
999 
1000 
1001 DECLARE_GENERIC_OBJECT_TYPE( std::vector<int> )
1002 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned> )
1003 DECLARE_GENERIC_OBJECT_TYPE( std::vector<char> )
1004 DECLARE_GENERIC_OBJECT_TYPE( std::vector<signed char> )
1005 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned char> )
1006 DECLARE_GENERIC_OBJECT_TYPE( std::vector<short> )
1007 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned short> )
1008 DECLARE_GENERIC_OBJECT_TYPE( std::vector<long> )
1009 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned long> )
1010 DECLARE_GENERIC_OBJECT_TYPE( std::vector<long long> )
1011 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned long long> )
1012 DECLARE_GENERIC_OBJECT_TYPE( std::vector<float> )
1013 DECLARE_GENERIC_OBJECT_TYPE( std::vector<double> )
1014 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::string> )
1015 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Object> )
1016 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Void> )
1017 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::string> * )
1018 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<int> > )
1019 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned> > )
1020 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<char> > )
1021 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<signed char> > )
1022 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned char> > )
1023 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<short> > )
1024 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned short> > )
1025 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<long> > )
1026 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned long> > )
1027 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<long long> > )
1028 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned long long> > )
1029 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<float> > )
1030 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<double> > )
1031 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<std::string> > )
1032 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::set<unsigned> > )
1033 
1034 DECLARE_GENERIC_OBJECT_TYPE( std::list<unsigned> )
1035 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::list<unsigned> > )
1036 
1037 DECLARE_GENERIC_OBJECT_TYPE( std::list<std::vector<std::string> > )
1038 
1039 DECLARE_GENERIC_OBJECT_TYPE( std::set<int> )
1040 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned> )
1041 DECLARE_GENERIC_OBJECT_TYPE( std::set<char> )
1042 DECLARE_GENERIC_OBJECT_TYPE( std::set<signed char> )
1043 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned char> )
1044 DECLARE_GENERIC_OBJECT_TYPE( std::set<short> )
1045 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned short> )
1046 DECLARE_GENERIC_OBJECT_TYPE( std::set<long> )
1047 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned long> )
1048 DECLARE_GENERIC_OBJECT_TYPE( std::set<long long> )
1049 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned long long> )
1050 DECLARE_GENERIC_OBJECT_TYPE( std::set<float> )
1051 DECLARE_GENERIC_OBJECT_TYPE( std::set<double> )
1052 DECLARE_GENERIC_OBJECT_TYPE( std::set<std::string> )
1053 DECLARE_GENERIC_OBJECT_TYPE( std::set<Object> )
1054 
1055 #define _TMP_ std::map< std::string, int >
1057 #undef _TMP_
1058 #define _TMP_ std::map< std::string, unsigned >
1060 #undef _TMP_
1061 #define _TMP_ std::map< std::string, char >
1063 #undef _TMP_
1064 #define _TMP_ std::map< std::string, signed char >
1066 #undef _TMP_
1067 #define _TMP_ std::map< std::string, unsigned char >
1069 #undef _TMP_
1070 #define _TMP_ std::map< std::string, short >
1072 #undef _TMP_
1073 #define _TMP_ std::map< std::string, unsigned short >
1075 #undef _TMP_
1076 #define _TMP_ std::map< std::string, long >
1078 #undef _TMP_
1079 #define _TMP_ std::map< std::string, unsigned long >
1081 #undef _TMP_
1082 #define _TMP_ std::map< std::string, long long >
1084 #undef _TMP_
1085 #define _TMP_ std::map< std::string, unsigned long long >
1087 #undef _TMP_
1088 #define _TMP_ std::map< std::string, float >
1090 #undef _TMP_
1091 #define _TMP_ std::map< std::string, double >
1093 #undef _TMP_
1094 #define _TMP_ std::map< std::string, bool >
1096 #undef _TMP_
1097 #define _TMP_ std::map< std::string, std::string >
1099 #undef _TMP_
1100 #define _TMP_ std::map< std::string, Object >
1102 #undef _TMP_
1103 #define TMP std::map< int, Object >
1105 #undef TMP
1106 #define TMP std::map< float, Object >
1108 #undef TMP
1109 #define TMP std::map< Object, Object >
1111 #undef TMP
1112 
1113 #define _TMP_ std::map< std::string, std::vector<int> >
1115 #undef _TMP_
1116 #define _TMP_ std::map< std::string, std::vector<unsigned> >
1118 #undef _TMP_
1119 #define _TMP_ std::map< std::string, std::vector<char> >
1121 #undef _TMP_
1122 #define _TMP_ std::map< std::string, std::vector<signed char> >
1124 #undef _TMP_
1125 #define _TMP_ std::map< std::string, std::vector<unsigned char> >
1127 #undef _TMP_
1128 #define _TMP_ std::map< std::string, std::vector<short> >
1130 #undef _TMP_
1131 #define _TMP_ std::map< std::string, std::vector<unsigned short> >
1133 #undef _TMP_
1134 #define _TMP_ std::map< std::string, std::vector<long> >
1136 #undef _TMP_
1137 #define _TMP_ std::map< std::string, std::vector<unsigned long> >
1139 #undef _TMP_
1140 #define _TMP_ std::map< std::string, std::vector<long long> >
1142 #undef _TMP_
1143 #define _TMP_ std::map< std::string, std::vector<unsigned long long> >
1145 #undef _TMP_
1146 #define _TMP_ std::map< std::string, std::vector<float> >
1148 #undef _TMP_
1149 #define _TMP_ std::map< std::string, std::vector<double> >
1151 #undef _TMP_
1152 #define _TMP_ std::map< std::string, std::vector<std::string> >
1154 #undef _TMP_
1155 #define _TMP_ std::map< std::string, std::vector<Object> >
1157 #undef _TMP_
1158 
1159 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<int> > )
1160 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned> > )
1161 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<char> > )
1162 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<signed char> > )
1163 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned char> > )
1164 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<short> > )
1165 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned short> > )
1166 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<long> > )
1167 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned long> > )
1168 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<long long> > )
1169 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned long long> > )
1170 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<float> > )
1171 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<double> > )
1172 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<Object> > )
1173 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<std::string> > )
1174 
1175 #define _TMP_ rc_ptr< std::map< std::string, int > >
1177 #undef _TMP_
1178 #define _TMP_ rc_ptr< std::map< std::string, unsigned > >
1180 #undef _TMP_
1181 #define _TMP_ rc_ptr< std::map< std::string, char > >
1183 #undef _TMP_
1184 #define _TMP_ rc_ptr< std::map< std::string, signed char > >
1186 #undef _TMP_
1187 #define _TMP_ rc_ptr< std::map< std::string, unsigned char > >
1189 #undef _TMP_
1190 #define _TMP_ rc_ptr< std::map< std::string, short > >
1192 #undef _TMP_
1193 #define _TMP_ rc_ptr< std::map< std::string, unsigned short > >
1195 #undef _TMP_
1196 #define _TMP_ rc_ptr< std::map< std::string, long > >
1198 #undef _TMP_
1199 #define _TMP_ rc_ptr< std::map< std::string, unsigned long > >
1201 #undef _TMP_
1202 #define _TMP_ rc_ptr< std::map< std::string, long long > >
1204 #undef _TMP_
1205 #define _TMP_ rc_ptr< std::map< std::string, unsigned long long > >
1207 #undef _TMP_
1208 #define _TMP_ rc_ptr< std::map< std::string, float > >
1210 #undef _TMP_
1211 #define _TMP_ rc_ptr< std::map< std::string, double > >
1213 #undef _TMP_
1214 #define _TMP_ rc_ptr< std::map< std::string, bool > >
1216 #undef _TMP_
1217 #define _TMP_ rc_ptr< std::map< std::string, std::string > >
1219 #undef _TMP_
1220 #define _TMP_ rc_ptr< std::map< std::string, Object > >
1222 #undef _TMP_
1223 #define _TMP_ rc_ptr< std::map< int, Object > >
1225 #undef _TMP_
1226 #define _TMP_ rc_ptr< std::map< float, Object > >
1228 #undef _TMP_
1229 #define TMP rc_ptr< std::map< Object, Object > >
1231 #undef TMP
1232 
1233 #define _TMP_ rc_ptr< std::map< std::string, std::vector<int> > >
1235 #undef _TMP_
1236 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned> > >
1238 #undef _TMP_
1239 #define _TMP_ rc_ptr< std::map< std::string, std::vector<char> > >
1241 #undef _TMP_
1242 #define _TMP_ rc_ptr< std::map< std::string, std::vector<signed char> > >
1244 #undef _TMP_
1245 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned char> > >
1247 #undef _TMP_
1248 #define _TMP_ rc_ptr< std::map< std::string, std::vector<short> > >
1250 #undef _TMP_
1251 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned short> > >
1253 #undef _TMP_
1254 #define _TMP_ rc_ptr< std::map< std::string, std::vector<long> > >
1256 #undef _TMP_
1257 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned long> > >
1259 #undef _TMP_
1260 #define _TMP_ rc_ptr< std::map< std::string, std::vector<long long> > >
1262 #undef _TMP_
1263 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned long long> > >
1265 #undef _TMP_
1266 #define _TMP_ rc_ptr< std::map< std::string, std::vector<float> > >
1268 #undef _TMP_
1269 #define _TMP_ rc_ptr< std::map< std::string, std::vector<double> > >
1271 #undef _TMP_
1272 #define _TMP_ rc_ptr< std::map< std::string, std::vector<std::string> > >
1274 #undef _TMP_
1275 #define _TMP_ rc_ptr< std::map< std::string, std::vector<Object> > >
1277 #undef _TMP_
1278 
1280 DECLARE_GENERIC_OBJECT_TYPE( Semantic )
1282 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr<SyntaxSet> )
1283 
1284 template <typename T>
1285 inline void object_to( Object o, T & r );
1286 template <>
1287 void object_to( Object o, bool &r );
1288 template <>
1289 void object_to( Object o, unsigned char &r );
1290 template <>
1291 void object_to( Object o, signed char &r );
1292 template <>
1293 inline void object_to( Object o, char &r );
1294 template <>
1295 void object_to( Object o, unsigned short &r );
1296 template <>
1297 void object_to( Object o, short &r );
1298 template <>
1299 void object_to( Object o, unsigned &r );
1300 template <>
1301 void object_to( Object o, int &r );
1302 template <>
1303 void object_to( Object o, float &r );
1304 template <>
1305 inline void object_to( Object o, double &r );
1306 template <>
1307 void object_to( Object o, std::string &r );
1308 template <>
1309 inline void object_to( Object o, Object & r );
1310 
1311 
1312 
1313  //----------------//
1314  // object_to<T> //
1315 //----------------//
1316 
1317 //-----------------------------------------------------------------------------
1318 template <typename T>
1319 inline void object_to( Object o, T & r )
1320 {
1321  r = o->GenericObject::value<T>();
1322 }
1323 
1324 //-----------------------------------------------------------------------------
1325 /* This specialization is a workaaround to avoid a bug in gcc 3.4.3 (at least).
1326  This function needs to be compiled and I really really don't know why.
1327  Otherwise it seems not to be called at all (hopefully)
1328 */
1329 template <typename T>
1330 inline void object_to( Object, const T & )
1331 {
1332  throw std::runtime_error( std::string( "cannot convert object to const " ) +
1333  DataTypeCode<T>::name() + " (this is probably a "
1334  "bug)" );
1335 }
1336 
1337 //-----------------------------------------------------------------------------
1338 template <>
1339 inline void object_to( Object o, Object & r )
1340 {
1341  r = o;
1342 }
1343 
1344 
1345 //-----------------------------------------------------------------------------
1346 template <>
1347 inline void object_to( Object o, char &r )
1348 {
1349 #ifdef __CHAR_UNSIGNED__
1350  object_to<unsigned char>( o, reinterpret_cast<unsigned char &>( r ) );
1351 #else
1352  object_to<signed char>( o, reinterpret_cast<signed char &>( r ) );
1353 #endif
1354 }
1355 
1356 
1357 
1358 
1359 //-----------------------------------------------------------------------------
1360 template <>
1361 inline void object_to( Object o, double &r )
1362 {
1363  r = o->getScalar();
1364 }
1365 
1366 
1367  //------------------------//
1368  // DictionaryInterface //
1369 //------------------------//
1370 
1371 
1372 //---------------------------------------------------------------------------
1373 template <typename T>
1374 void DictionaryInterface::setProperty( const std::string &,
1375  const T &value )
1376 {
1377  you_must_use_DECLARE_GENERIC_OBJECT_TYPE( value );
1378 }
1379 
1380 
1381 //---------------------------------------------------------------------------
1382 template <typename T>
1383 bool DictionaryInterface::getProperty( const std::string &, T &value ) const
1384 {
1385  return you_must_use_DECLARE_GENERIC_OBJECT_TYPE( value );
1386 }
1387 
1388 
1389  //-----------------//
1390  // GenericObject //
1391 //-----------------//
1392 
1393 //-----------------------------------------------------------------------------
1394 template <class T>
1396 {
1397  return dynamic_cast<T *>( _getGenericInterface() );
1398 }
1399 
1400 //-----------------------------------------------------------------------------
1401 template <class T>
1402 inline const T *GenericObject::getInterface() const
1403 {
1404  /* using const_cast is ugly, OK, right.
1405  But it avoids redefining a const version of _getGenericInterface() with
1406  exactly the same contents. I'm lazy today.
1407  */
1408  return dynamic_cast<T *>( const_cast<GenericObject *>( this )
1409  ->_getGenericInterface() );
1410 }
1411 
1412 
1413  //----------//
1414  // Object //
1415 //----------//
1416 
1417 
1418 //-----------------------------------------------------------------------------
1420 {
1421 }
1422 
1423 //-----------------------------------------------------------------------------
1424 inline Object::Object( const Object &x ) : rc_ptr<GenericObject>( x )
1425 {
1426 }
1427 
1428 //-----------------------------------------------------------------------------
1429 inline Object::Object( GenericObject *x, bool externalowner )
1430  : rc_ptr<GenericObject>( x, externalowner )
1431 {
1432 }
1433 
1434 //-----------------------------------------------------------------------------
1436 {
1437 }
1438 
1439 
1440 //-----------------------------------------------------------------------------
1441 inline Object & Object::operator = ( const Object &other )
1442 {
1443  if ( this != &other ) {
1445  ( static_cast< const rc_ptr<GenericObject> & >( other ) );
1446  }
1447  return *this;
1448 }
1449 
1450 
1451 //-----------------------------------------------------------------------------
1452 inline bool Object::operator == ( const Object &other ) const
1453 {
1454  if ( this == &other || ( !get() && !other.get() ) )
1455  return true;
1456  if( !get() || !other.get() )
1457  return false;
1458  return *get() == *other.get();
1459 }
1460 
1461 
1462 #if 0
1463 //-----------------------------------------------------------------------------
1464 template <typename T, bool>
1465 class ObjectValueTrait
1466 {
1467 public:
1468  static inline Object value()
1469  {
1470  return Object( static_cast<GenericObject *>( new ValueObject<T>() ) );
1471  }
1472  static inline Object value( const T &v )
1473  {
1474  return Object( static_cast<GenericObject *>( new ValueObject<T>( v ) ) );
1475  }
1476 };
1477 
1478 //-----------------------------------------------------------------------------
1479 template <typename T>
1480 class ObjectValueTrait<T,true>
1481 {
1482 public:
1483  static inline Object value()
1484  {
1485  return Object( (GenericObject *) new T );
1486  }
1487  static inline Object value( const T &v )
1488  {
1489  return v.clone();
1490  }
1491 };
1492 #endif
1493 
1494 //-----------------------------------------------------------------------------
1495 template <typename T>
1497 {
1498  return Object( static_cast<GenericObject *>( new ValueObject<T>() ) );
1499  // return ObjectValueTrait< T, SUPERSUBCLASS(GenericObject,T) >::value();
1500 }
1501 
1502 
1503 //-----------------------------------------------------------------------------
1504 template <typename T>
1505 inline Object Object::value( const T &v )
1506 {
1507  return Object( static_cast<GenericObject *>( new ValueObject<T>( v ) ) );
1508  // return ObjectValueTrait< T, SUPERSUBCLASS(GenericObject,T) >::value( v );
1509 }
1510 
1511 
1512 //-----------------------------------------------------------------------------
1513 template <>
1514 inline Object Object::value( const Object &value )
1515 {
1516  return value;
1517 }
1518 
1519 
1520 #if 0
1521 //-----------------------------------------------------------------------------
1522 template <typename T, bool>
1523 class ObjectReferenceTrait
1524 {
1525 public:
1526  static inline Object reference( T &v )
1527  {
1528  return Object( static_cast< GenericObject *>( new ReferenceObject<T>( v ) ) );
1529  }
1530 };
1531 
1532 //-----------------------------------------------------------------------------
1533 template <typename T>
1534 class ObjectReferenceTrait<T,true>
1535 {
1536 public:
1537  static inline Object reference( T &v )
1538  {
1539  return Object( &v );
1540  }
1541 };
1542 #endif
1543 
1544 //-----------------------------------------------------------------------------
1545 template <typename T>
1546 inline Object Object::reference( T &value )
1547 {
1548  return Object( static_cast< GenericObject *>( new ReferenceObject<T>( value ) ) );
1549  // return ObjectReferenceTrait< T, SUPERSUBCLASS( GenericObject, T ) >::reference( value );
1550 }
1551 
1552 
1553 //-----------------------------------------------------------------------------
1554 template <typename T>
1555 inline Object Object::reference( const T &value )
1556 {
1557  return Object::reference( const_cast< T & >( value ) );
1558 }
1559 
1560 //-----------------------------------------------------------------------------
1561 template <>
1563 {
1564  return value;
1565 }
1566 
1567 
1568 //-----------------------------------------------------------------------------
1569 inline bool Object::isNone() const
1570 {
1571  // may be replaced by a comparison to the global none object
1572  return get() == 0;
1573 }
1574 
1575 
1576  //--------------------------------//
1577  // DataTypeCode<ValueObject<T>> //
1578 //--------------------------------//
1579 
1580 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
1581 
1582 template<typename T> class DataTypeCode< ValueObject<T> >
1583 {
1584  public:
1585  static inline std::string objectType()
1586  { return "ValueObject"; }
1587  static inline std::string dataType()
1588  { return DataTypeCode<T>::name(); }
1589  static inline std::string name()
1590  {
1591  return std::string("ValueObject of ") + DataTypeCode< T >::name();
1592  }
1593 };
1594 
1595 #endif
1596 
1597  //------------------------//
1598  // DataTypeCode<Object> //
1599 //------------------------//
1600 
1601 //-----------------------------------------------------------------------------
1602 template<> inline std::string DataTypeCode<Object>::dataType()
1603 {
1604  return "object";
1605 }
1606 
1607 
1608 //-----------------------------------------------------------------------------
1609 template<> inline std::string DataTypeCode<Object>::objectType()
1610 {
1611  return "object";
1612 }
1613 
1614 
1615 //-----------------------------------------------------------------------------
1616 template<> inline std::string DataTypeCode<Object>::name()
1617 {
1618  return "object";
1619 }
1620 
1621 
1622  //-------------------------------//
1623  // DataTypeCode<GenericObject> //
1624 //-------------------------------//
1625 
1626 //-----------------------------------------------------------------------------
1627 template<> inline std::string DataTypeCode<GenericObject>::dataType()
1628 {
1629  return "any";
1630 }
1631 
1632 
1633 //-----------------------------------------------------------------------------
1634 template<> inline std::string DataTypeCode<GenericObject>::objectType()
1635 {
1636  return "genericobject";
1637 }
1638 
1639 
1640 //-----------------------------------------------------------------------------
1641 template<> inline std::string DataTypeCode<GenericObject>::name()
1642 {
1643  return "genericobject";
1644 }
1645 
1646 
1647 
1648  //------------------------------------//
1649  // DataTypeCode<ReferenceObject<T>> //
1650 //------------------------------------//
1651 
1652 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
1653 
1654 template<typename T> class DataTypeCode< ReferenceObject<T> >
1655 {
1656  public:
1657  static inline std::string objectType()
1658  { return "ReferenceObject"; }
1659  static inline std::string dataType()
1660  { return DataTypeCode<T>::name(); }
1661  static inline std::string name()
1662  {
1663  return std::string("ReferenceObject of ") + DataTypeCode< T >::name();
1664  }
1665 };
1666 
1667 #endif
1668 
1669 
1670 //-----------------------------------------------------------------------------
1671 
1672 
1673 } // namespace carto
1674 
1675 
1676 #endif
bool operator==(const carto::block< T, N > &b1, const carto::block< T, N > &b2)
Definition: block.h:252
#define CARTOBASE_API
Void does not contain anything.
Definition: types.h:61
ArrayInterface represents any container whose elements can be accessed via an integer index.
Definition: object.h:336
virtual bool hasItem(int index) const =0
Tells if array item index actually exists.
virtual Object getArrayItem(int index) const =0
Get the element of index index.
virtual bool isContiguous() const =0
Tells if array indices are contiguous (as in a vector), contrarily to an int key dictionary.
virtual void setArrayItem(int, Object)=0
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 =0
Number of sub-elements.
static std::string objectType()
Definition: object.h:1585
This class is just a hint to convert an actual data type to an identifier string used in input/output...
Definition: types.h:111
static std::string name()
Definition: types.h:243
static std::string objectType()
Definition: types.h:223
static std::string dataType()
Definition: types.h:230
Interface for dictionary-like objects.
Definition: object.h:414
virtual bool hasProperty(const std::string &key) const =0
check if an element exists under the key key
virtual bool removeProperty(const std::string &)=0
remove an element.
virtual bool getProperty(const std::string &key, Object &value) const =0
Access the element ok key key.
void setProperty(const std::string &, const char *)
specific specialization: C strings are stored as std::string objects
virtual void copyProperties(Object source)
copy all properties of the source object to this object.
virtual void clearProperties()
clear the dictionary
virtual bool operator!=(const DictionaryInterface &other) const
Definition: object.h:479
Object getProperty(Object key) const
same as the other getProperty() functions except that the key is contained in the key argument (which...
Object getProperty(const std::string &) const
same as the other getProperty() functions except that the value object is returned.
virtual bool operator==(const DictionaryInterface &other) const
equality test
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
virtual void setProperty(const std::string &key, Object value)=0
Set (insert or replace) the element of key key with the value object.
Specialized IteratorInterface for dictionaries.
Definition: object.h:289
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...
A dynamic array has resize and insertion capabilities (like a STL vector)
Definition: object.h:374
virtual void removeArrayItem(int)=0
removes an element from the array.
virtual void resizeArray(size_t)=0
resize the array.
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
virtual void reserveArray(size_t)=0
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.
base abstract generic object class.
Definition: object.h:545
const T & value() const
Retrieve value in object, const reference.
Definition: object_d.h:126
void setValue(const T &val)
Store value in object by copying it.
Definition: object_d.h:167
virtual ~GenericObject()
virtual Interface * _getGenericInterface()=0
virtual Object clone() const =0
cloning copy
virtual std::string type() const =0
type() returns the DataTypeCode::name() of the underlying object type
virtual void setValue(Object val)=0
T * getInterface()
Obtain a specific Interface subclass.
Definition: object.h:1395
virtual const void * _getAddressOfValue() const =0
virtual size_t size() const =0
Number of sub-elements.
Specialized IteratorInterface for dictionaries.
Definition: object.h:313
virtual bool isIntKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual long intKey() const =0
Access the key of the current dictionary element.
virtual ~Interface()
Container objects which can be iterated.
Definition: object.h:197
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
virtual Object objectIterator() const =0
returns an object implementing the IteratorIntrerface
virtual bool operator==(const IterableInterface &other) const
equality test
virtual bool operator!=(const IterableInterface &other) const
Definition: object.h:211
An iterator object is a reference to another object.
Definition: object.h:236
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
virtual Object currentValue() const =0
Access the value of the element pointed to by the iterator.
virtual void next()=0
Point to the next element of the iterable container.
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...
Specialized IteratorInterface for key/value storage.
Definition: object.h:265
virtual Object keyObject() const =0
Access the key of the current element.
virtual bool isKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
Specialized NoneInterface for empty objects (null, None).
Definition: object.h:516
virtual bool isNone() const =0
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
virtual ~NoneInterface()
Object & operator=(const Object &)
uses the reference-counting so the underlying GenericObject is shared
Definition: object.h:1441
static Object reference(T &value)
factory function: builds an Object by referencing the value from a ReferenceObject storage wrapper.
Definition: object.h:1546
bool operator!=(const Object &other) const
Definition: object.h:660
bool isSameObject(const Object &) const
compares the addresses of the underlying GenericObjects
static Object value()
factory function: builds an Object by using the default constructor
Definition: object.h:1496
bool operator==(const Object &other) const
Definition: object.h:1452
virtual ~Object()
Definition: object.h:1435
bool isNone() const
check if we hold a "none" object.
Definition: object.h:1569
PointerObject(T &x, bool owner)
Definition: object_d.h:803
virtual ~PointerObject()
Definition: object_d.h:810
virtual T & getValue()
Definition: object_d.h:818
virtual Object clone() const
cloning copy
Definition: object_d.h:825
Base class for reference counted objects (intrusive)
Definition: rcptr.h:110
storage wrapper, derived and instanciable template class
Definition: object.h:879
virtual T & getValue()
Definition: object_d.h:784
virtual Object clone() const
cloning copy
Definition: object_d.h:791
virtual ~ReferenceObject()
Definition: object_d.h:777
All scalar numbers implement the ScalarInterface (all ints, float, double...)
Definition: object.h:110
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
virtual bool operator!=(const ScalarInterface &other) const
Definition: object.h:133
virtual double getScalar() const =0
Obtain a scalar value, possibly after a conversion.
virtual bool operator==(const ScalarInterface &other) const
equality test
virtual void setScalar(double)=0
The double value will be converted to the actual storage type before it is set in the contained objec...
All container objects inherit the SizeInterface.
Definition: object.h:178
virtual ~SizeInterface()
virtual size_t size() const =0
Number of sub-elements.
Objects whose value may be represented as a character string.
Definition: object.h:144
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
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...
virtual bool operator==(const StringInterface &other) const
equality test
virtual bool operator!=(const StringInterface &other) const
Definition: object.h:167
virtual std::string getString() const =0
Obtain a string value, possibly after a conversion.
A Syntaxed object is an object containing an additional character string giving it a kind of type (a ...
Definition: object.h:494
virtual bool operator==(const SyntaxedInterface &other) const
equality test
virtual bool hasSyntax() const =0
virtual bool operator!=(const SyntaxedInterface &other) const
Definition: object.h:504
virtual void setSyntax(const std::string &syntactic)=0
virtual std::string getSyntax() const =0
storage wrapper, derived but still abstract template class
Definition: object.h:671
virtual long intKey() const
Access the key of the current dictionary element.
Definition: object_d.h:675
virtual bool isContiguous() const
Tells if array indices are contiguous (as in a vector), contrarily to an int key dictionary.
Definition: object_d.h:371
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
Definition: object_d.h:556
virtual bool isKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
Definition: object_d.h:615
virtual Object keyObject() const
Access the key of the current element.
Definition: object_d.h:625
virtual Object clone() const
cloning copy
Definition: object_d.h:249
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
Definition: object_d.h:412
virtual void setValue(Object val)
Definition: object_d.h:209
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
Definition: object_d.h:590
virtual void insertArrayItem(int, Object)
inserts an element into the array.
Definition: object_d.h:451
virtual void removeArrayItem(int)
removes an element from the array.
Definition: object_d.h:441
virtual void setScalar(double)
The double value will be converted to the actual storage type before it is set in the contained objec...
Definition: object_d.h:316
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
Definition: object_d.h:571
virtual Object getArrayItem(int index) const
Get the element of index index.
Definition: object_d.h:387
virtual std::string key() const
Access the key of the current dictionary element.
Definition: object_d.h:650
virtual bool isIntKeyIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
Definition: object_d.h:665
virtual std::string getString() const
Obtain a string value, possibly after a conversion.
Definition: object_d.h:339
virtual void clearProperties()
clear the dictionary
Definition: object_d.h:522
virtual void reserveArray(size_t)
like the STL vector::reserve(), memory is reserved but no element is stored
Definition: object_d.h:421
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
Definition: object_d.h:640
virtual T & getValue()
Definition: object_d.h:241
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
Definition: object_d.h:547
virtual void resizeArray(size_t)
resize the array.
Definition: object_d.h:431
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...
Definition: object_d.h:348
virtual bool isArray() const
Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since al...
Definition: object_d.h:362
virtual size_t size() const
Number of sub-elements.
Definition: object_d.h:467
virtual bool removeProperty(const std::string &)
remove an element.
Definition: object_d.h:512
virtual bool operator==(const GenericObject &other) const
Definition: object_d.h:700
virtual ~TypedObject()
Definition: object_d.h:194
virtual bool hasItem(int index) const
Tells if array item index actually exists.
Definition: object_d.h:379
virtual bool hasProperty(const std::string &) const
check if an element exists under the key key
Definition: object_d.h:532
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
Definition: object_d.h:481
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
Definition: object_d.h:330
virtual double getScalar() const
Obtain a scalar value, possibly after a conversion.
Definition: object_d.h:307
virtual bool isValid() const
true if the iterator points to a valid value, false when the end of the iterable container has been r...
Definition: object_d.h:580
virtual void setProperty(const std::string &key, Object value)=0
Set (insert or replace) the element of key key with the value object.
virtual bool getProperty(const std::string &key, Object &value) const=0
Access the element ok key key.
virtual void next()
Point to the next element of the iterable container.
Definition: object_d.h:600
virtual std::string type() const
type() returns the DataTypeCode::name() of the underlying object type
Definition: object_d.h:217
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
Definition: object_d.h:298
virtual bool isNone() const
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
Definition: object_d.h:690
virtual void setArrayItem(int, Object)
Definition: object_d.h:397
storage wrapper, derived and instanciable template class
Definition: object.h:841
virtual ~ValueObject()
Definition: object_d.h:743
virtual T & getValue()
Definition: object_d.h:750
virtual Object clone() const
cloning copy
Definition: object_d.h:758
Reference-counting pointer.
Definition: rcptr.h:640
GenericObject * get() const
Definition: rcptr.h:666
std::map< int, Object > IntDictionary
Definition: object.h:867
void object_to(Object o, T &r)
Definition: object.h:1319
std::map< std::string, Object > Dictionary
Common type used for DictionaryInterface implementation.
Definition: object.h:866
std::map< std::string, Syntax > SyntaxSet
This lookup table associates a syntactic attribute with its syntax.
Definition: syntax.h:83
std::map< Object, Object > ObjectDictionary
Definition: object.h:868
std::vector< Object > ObjectVector
Common type used for ArrayInterface implementation.
Definition: object.h:870
Object none()
An empty singleton object (holds a null pointer)
SemanticSet Syntax
Specify syntax for syntactic attributes.
Definition: syntax.h:78
#define _TMP_
Definition: object.h:1275
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Definition: object.h:56
#define TMP
Definition: object.h:1229
Class to force a compilation error when a generic object.
Definition: object.h:768
static void check(T *x=NULL)
Definition: object.h:769