Version: 9.16.0
TypeCode.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef __TYPECODE_HXX__
21#define __TYPECODE_HXX__
22
24#include "RefCounter.hxx"
25#include "Exception.hxx"
26#include "Any.hxx"
27
28#include <string>
29#include <list>
30
31namespace YACS
32{
33 namespace ENGINE
34 {
35 class Visitor;
36
37 typedef enum
38 {
39 NONE = 0,
40 Double = 1,
41 Int = 2,
42 String = 3,
43 Bool = 4,
44 Objref = 5,
46 Array = 7,
47 Struct = 8
49
50// typedef enum DynType StreamType;
51
52 class TypeCodeObjref;
53
68 {
69 public:
70 TypeCode(DynType kind);
71
72 DynType kind() const;
73 const char * getKindRepr() const;
74 const TypeCode *subContentType(int lev) const;
75 virtual TypeCode *clone() const;
76 virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
77 virtual void destroyZippedAny(char *data) const;
78 virtual AnyPtr getOrBuildAnyFromZippedData(char *data) const;
79 virtual const char * name() const;
80 virtual const char * shortName() const;
81 virtual const char * id() const;
82 virtual const TypeCode * contentType() const;
83 virtual int isA(const char* repositoryId) const;
84 virtual int isA(const TypeCode* tc) const ;
85 virtual int isAdaptable(const TypeCode* tc) const;
86 virtual int isEquivalent(const TypeCode* tc) const;
87 virtual unsigned getSizeInByteOfAnyReprInSeq() const;
88 virtual std::string getPrintStr() const;
89
90 static const char *getKindRepr(DynType kind);
91 static TypeCode * interfaceTc(const char* id, const char* name);
92 static TypeCode * interfaceTc(const char* id, const char* name, const std::list<TypeCodeObjref *>& ltc);
93 static TypeCode * sequenceTc (const char* id, const char* name, TypeCode *content);
94 static TypeCode * structTc (const char* id, const char* name);
95
96 protected:
97 // --- These operators are placed here to avoid them being used externally
98 TypeCode(const TypeCode& tc);
100#ifndef SWIG
101 virtual ~TypeCode();
102#endif
103 protected:
105 static const char *KIND_STR_REPR [];
106 };
107
109 {
110 protected:
112 TypeCodeComposed(DynType kind, const char* repositoryId, const char* name);
113 protected:
114 const std::string _name;
115 const std::string _repoId;
116 std::string _shortName;
117 };
118
119
126 {
127 friend class Visitor;
128 public:
129 TypeCodeObjref(const char* repositoryId, const char* name);
130
131 TypeCodeObjref(const char* repositoryId, const char* name, const std::list<TypeCodeObjref *>& ltc);
132
133 TypeCode *clone() const;
134 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
135 void destroyZippedAny(char *data) const;
136 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
137 const char * id() const;
138 const char * name() const;
139 const char * shortName() const;
140 int isA(const char* repositoryId) const;
141 virtual int isA(const TypeCode* tc) const ;
142 virtual int isAdaptable(const TypeCode* tc) const;
143 virtual int isEquivalent(const TypeCode* tc) const;
144 protected:
145#ifndef SWIG
146 virtual ~TypeCodeObjref();
147#endif
148 TypeCodeObjref(const TypeCodeObjref& other);
149 private:
150 std::list<TypeCodeObjref *> _listOfBases;
151 };
152
153
160 {
161 public:
162 TypeCodeSeq(const char* repositoryId, const char* name, const TypeCode *content);
163
164 TypeCode *clone() const;
165 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
166 void destroyZippedAny(char *data) const;
167 virtual unsigned getSizeInByteOfAnyReprInSeq() const;
168 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
169 const char * id() const;
170 const char * name() const;
171 const char * shortName() const;
172 virtual std::string getPrintStr() const;
173
174 virtual const TypeCode * contentType() const;
175 virtual int isA(const TypeCode* tc) const ;
176 virtual int isAdaptable(const TypeCode* tc) const;
177 virtual int isEquivalent(const TypeCode* tc) const;
178 protected:
179#ifndef SWIG
180 virtual ~TypeCodeSeq();
181#endif
182 TypeCodeSeq(const TypeCodeSeq& tc);
183 private:
185 };
186
193 {
194 public:
195 TypeCodeArray(const char* repositoryId, const char* name, const TypeCode *content, unsigned staticLgth);
196 TypeCode *clone() const;
197 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
198 void destroyZippedAny(char *data) const;
199 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
200 const char * id() const;
201 const char * name() const;
202 const char * shortName() const;
203 unsigned getStaticLgth() const;
204
205 virtual const TypeCode * contentType() const;
206 virtual int isA(const TypeCode* tc) const ;
207 virtual int isAdaptable(const TypeCode* tc) const;
208 virtual int isEquivalent(const TypeCode* tc) const;
209 unsigned getSizeInByteOfAnyReprInSeq() const;
210 protected:
211#ifndef SWIG
212 virtual ~TypeCodeArray();
213#endif
214 TypeCodeArray(const TypeCodeArray& tc);
215 private:
217 const unsigned _staticLgth;
218 };
219
220 class StructAny;
221
228 {
229 friend class StructAny;//Access to _members attribute.
230 public:
231 TypeCodeStruct(const char* repositoryId, const char* name);
232 TypeCode *clone() const;
233 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
234 void destroyZippedAny(char *data) const;
235 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
236 const char * id() const;
237 const char * name() const;
238 const char * shortName() const;
239 virtual unsigned getSizeInByteOfAnyReprInSeq() const;
240 const TypeCode * contentType() const;
241 virtual int isA(const char* repositoryId) const;
242 virtual int isA(const TypeCode* tc) const ;
243 virtual int isAdaptable(const TypeCode* tc) const;
244 virtual int isEquivalent(const TypeCode* tc) const;
246 virtual void addMember(const std::string& name,TypeCode* tc);
247 const TypeCode *getMember(const std::string& name, unsigned& offset) const;
248 int memberCount() const;
249 const char* memberName(int index) const;
250 TypeCode* memberType(int index) const;
251 protected:
252#ifndef SWIG
253 virtual ~TypeCodeStruct();
254#endif
256 private:
257 std::vector< std::pair<std::string,TypeCode*> > _members;
258 };
259
260 }
261}
262#endif
#define YACSLIBENGINE_EXPORT
: Allow to manage memory of instances of T. The only constraint on T is to have method incrRef and De...
Definition: SharedPtr.hxx:30
Class for array objects.
Definition: TypeCode.hxx:193
const TypeCode * _content
Definition: TypeCode.hxx:216
const unsigned _staticLgth
Definition: TypeCode.hxx:217
const std::string _repoId
Definition: TypeCode.hxx:115
Class for reference objects.
Definition: TypeCode.hxx:126
std::list< TypeCodeObjref * > _listOfBases
Definition: TypeCode.hxx:150
Class for sequence objects.
Definition: TypeCode.hxx:160
const TypeCode * _content
Definition: TypeCode.hxx:184
Class for struct type.
Definition: TypeCode.hxx:228
std::vector< std::pair< std::string, TypeCode * > > _members
Definition: TypeCode.hxx:257
Base class for all type objects.
Definition: TypeCode.hxx:68
const DynType _kind
Definition: TypeCode.hxx:104
TypeCode & operator=(const TypeCode &tc)
int isAdaptable(const TypeCode *t1, const TypeCode *t2)