cartobase  5.0.5
syntobject.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_SYNTOBJECT_H
35 #define CARTOBASE_OBJECT_SYNTOBJECT_H
36 
40 
41 
42 namespace carto
43 {
44 
45  class PropertySet;
46 
47  namespace internal
48  {
49 
50  template<typename T> class SyntaxedNonInterfaceObject
51  : public ValueObject<T>, public SyntaxedInterface
52  {
53  public:
54  SyntaxedNonInterfaceObject( const std::string& s );
57 
58  virtual bool hasSyntax() const;
59  virtual std::string getSyntax() const;
60  virtual void setSyntax( const std::string& syntactic );
61 
62  private:
63  std::string _syntactic;
64  };
65 
66 
67  template <typename T>
69  : public T, public SyntaxedInterface
70  {
71  public:
72  SyntaxedInterfaceType( const std::string & s = "" );
74  virtual ~SyntaxedInterfaceType();
75 
76  virtual bool hasSyntax() const;
77  virtual std::string getSyntax() const;
78  virtual void setSyntax( const std::string& syntactic );
79 
80  private:
81  std::string _syntactic;
82  };
83 
84 
85  template <typename T>
87  : public ValueObject<SyntaxedInterfaceType<T> >
88  {
89  public:
90  SyntaxedInterfaceObject( const std::string & s )
92  { this->getValue().setSyntax( s ); }
93  virtual bool hasSyntax() const { return true; }
94  virtual std::string getSyntax() const
95  { return const_cast<SyntaxedInterfaceObject *>( this )->
96  getValue().getSyntax(); }
97  virtual void setSyntax( const std::string & s )
98  { this->getValue().setSyntax( s ); }
99  };
100 
101 
102  template <typename T, bool x>
104  {
105  };
106 
107 
108  template <typename T>
109  class SyntaxedObjectSwitch<T, true>
110  {
111  public:
114  };
115 
116 
117  template <typename T>
118  class SyntaxedObjectSwitch<T, false>
119  {
120  public:
122  typedef T ContentType;
123  };
124 
125  } // namespace internal
126 
127 
128  template <typename T>
130  : public internal::SyntaxedObjectSwitch<T, SUPERSUBCLASS(Interface, T)>::
131  ObjectType
132  {
133  public:
134  SyntaxedObject( const std::string & s )
135  : internal::SyntaxedObjectSwitch<T, SUPERSUBCLASS(Interface, T)>::
136  ObjectType( s )
137  {}
139  : internal::SyntaxedObjectSwitch<T, SUPERSUBCLASS(Interface, T)>::
140  ObjectType( x )
141  {}
142  typedef typename internal::SyntaxedObjectSwitch<T,
144  };
145 
146 
147  // definitions
148 
149  namespace internal
150  {
151 
152  template<typename T> inline
154  ( const std::string & s )
155  : ValueObject<T>(), _syntactic( s )
156  {
157  }
158 
159  template<typename T> inline
162  : RCObject(),
163  Interface(),
164  StringInterface(),
165  ScalarInterface(),
166  SizeInterface(),
168  ArrayInterface(),
173  ValueObject<T>( x ),
175  _syntactic( x._syntactic )
176  {
177  }
178 
179  template<typename T> inline
181  {
182  return true;
183  }
184 
185  template<typename T> inline
187  {
188  return _syntactic;
189  }
190 
191  template<typename T> inline
193  ( const std::string& syntactic )
194  {
195  _syntactic = syntactic;
196  }
197 
198  //
199 
200  template<typename T> inline
203  : Interface(),
204  T( x ),
206  _syntactic( x._syntactic )
207  {
208  }
209 
210  template <>
211  inline
214  : RCObject(),
215  Interface(),
216  PropertySet( x ),
218  _syntactic( x._syntactic )
219  {
220  }
221 
222  template<typename T> inline
224  : T(), SyntaxedInterface(), _syntactic( s )
225  {
226  }
227 
228  template<typename T> inline
230  {
231  return true;
232  }
233 
234  template<typename T> inline
236  {
237  return _syntactic;
238  }
239 
240  template<typename T> inline
241  void SyntaxedInterfaceType<T>::setSyntax( const std::string& syntactic )
242  {
243  _syntactic = syntactic;
244  }
245 
246  extern template class SyntaxedNonInterfaceObject<Dictionary>;
247  extern template class SyntaxedInterfaceType<PropertySet>;
248  extern template class SyntaxedInterfaceObject<PropertySet>;
249  }
250 
252 }
253 
254 namespace carto
255 {
256 
257  template <>
258  inline
260  const SyntaxedObject<PropertySet> & x )
261  : RCObject(),
262  Interface(),
263  StringInterface(),
264  ScalarInterface(),
265  SizeInterface(),
267  ArrayInterface(),
274  NoneInterface(),
275  internal::SyntaxedObjectSwitch<PropertySet,
276  SUPERSUBCLASS(Interface, PropertySet)>::ObjectType( x )
277  {
278  }
279 
280 }
281 
282 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Definition: object.h:56
Objects whose value may be represented as a character string.
Definition: object.h:143
SyntaxedInterfaceObject< T > ObjectType
Definition: syntobject.h:112
SyntaxedNonInterfaceObject(const std::string &s)
Definition: syntobject.h:154
SyntaxedNonInterfaceObject< T > ObjectType
Definition: syntobject.h:121
virtual void setSyntax(const std::string &syntactic)
Definition: syntobject.h:241
Specialized NoneInterface for empty objects (null, None).
Definition: object.h:506
virtual std::string getSyntax() const
Definition: syntobject.h:235
ArrayInterface represents any container whose elements can be accessed via an integer index...
Definition: object.h:334
virtual T & getValue()
Definition: object_d.h:734
Base class for reference counted objects (intrusive)
Definition: rcptr.h:106
Container objects which can be iterated.
Definition: object.h:196
storage wrapper, derived and instanciable template class
Definition: object.h:829
#define SUPERSUBCLASS(T, U)
Definition: conversion.h:86
SyntaxedObject(const std::string &s)
Definition: syntobject.h:134
Specialized IteratorInterface for key/value storage.
Definition: object.h:264
Specialized IteratorInterface for dictionaries.
Definition: object.h:312
All scalar numbers implement the ScalarInterface (all ints, float, double...)
Definition: object.h:109
Specialized IteratorInterface for dictionaries.
Definition: object.h:288
A Syntaxed object is an object containing an additional character string giving it a kind of type (a ...
Definition: object.h:484
A dictionary generic Object.
Definition: property.h:75
All container objects inherit the SizeInterface.
Definition: object.h:177
SyntaxedInterfaceObject(const std::string &s)
Definition: syntobject.h:90
SyntaxedObject(const SyntaxedObject &x)
Definition: syntobject.h:138
virtual void setSyntax(const std::string &s)
Definition: syntobject.h:97
virtual void setSyntax(const std::string &syntactic)
Definition: syntobject.h:193
virtual std::string getSyntax() const
Definition: syntobject.h:186
internal::SyntaxedObjectSwitch< T, SUPERSUBCLASS(Interface, T)>::ContentType ContentType
Definition: syntobject.h:143
virtual std::string getSyntax() const
Definition: syntobject.h:94
A dynamic array has resize and insertion capabilities (like a STL vector)
Definition: object.h:364
SyntaxedInterfaceType(const std::string &s="")
Definition: syntobject.h:223
An iterator object is a reference to another object.
Definition: object.h:235
Interface for dictionary-like objects.
Definition: object.h:403