cartobase 6.0.6
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
42namespace 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>
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
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
202 ( const SyntaxedInterfaceType< T > & x )
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
254namespace carto
255{
256
257 template <>
258 inline
279
280}
281
282#endif
ArrayInterface represents any container whose elements can be accessed via an integer index.
Definition object.h:336
Interface for dictionary-like objects.
Definition object.h:414
Specialized IteratorInterface for dictionaries.
Definition object.h:289
A dynamic array has resize and insertion capabilities (like a STL vector)
Definition object.h:374
Specialized IteratorInterface for dictionaries.
Definition object.h:313
Container objects which can be iterated.
Definition object.h:197
An iterator object is a reference to another object.
Definition object.h:236
Specialized IteratorInterface for key/value storage.
Definition object.h:265
Specialized NoneInterface for empty objects (null, None).
Definition object.h:516
A dictionary generic Object.
Definition property.h:77
Base class for reference counted objects (intrusive)
Definition rcptr.h:110
All scalar numbers implement the ScalarInterface (all ints, float, double...)
Definition object.h:110
All container objects inherit the SizeInterface.
Definition object.h:178
Objects whose value may be represented as a character string.
Definition object.h:144
A Syntaxed object is an object containing an additional character string giving it a kind of type (a ...
Definition object.h:494
internal::SyntaxedObjectSwitch< PropertySet, SUPERSUBCLASS(Interface, PropertySet)>::ContentType ContentType
Definition syntobject.h:143
SyntaxedObject(const std::string &s)
Definition syntobject.h:134
SyntaxedObject(const SyntaxedObject &x)
Definition syntobject.h:138
virtual void setSyntax(const std::string &s)
Definition syntobject.h:97
virtual std::string getSyntax() const
Definition syntobject.h:94
SyntaxedInterfaceObject(const std::string &s)
Definition syntobject.h:90
virtual std::string getSyntax() const
Definition syntobject.h:235
SyntaxedInterfaceType(const std::string &s="")
Definition syntobject.h:223
virtual void setSyntax(const std::string &syntactic)
Definition syntobject.h:241
SyntaxedNonInterfaceObject(const std::string &s)
Definition syntobject.h:154
virtual void setSyntax(const std::string &syntactic)
Definition syntobject.h:193
virtual std::string getSyntax() const
Definition syntobject.h:186
SyntaxedNonInterfaceObject< T > ObjectType
Definition syntobject.h:121
#define SUPERSUBCLASS(T, U)
Definition conversion.h:86
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Definition object.h:56