3 * MICO --- an Open Source CORBA implementation
4 * Copyright (c) 1997-2001 by The Mico Team
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * For more information, visit the MICO Home Page at
21 * http://www.mico.org/
24 #ifndef __mico_typecode_h__
25 #define __mico_typecode_h__
29 class TypeCode : public ServerlessObject {
33 std::vector<std::string> namevec;
34 std::vector<TypeCode_ptr> tcvec;
35 std::vector<Any *> labelvec;
36 std::vector<Visibility> visvec;
38 TypeCode_ptr discriminator;
39 TypeCode_ptr recurse_tc;
46 ValueModifier value_mod;
49 void copy (const TypeCode &);
52 typedef std::pair<TypeCode_ptr, TypeCode_ptr> PairTC;
53 typedef std::set<PairTC, std::less<PairTC> > SetTC;
54 typedef std::map<ULong, std::pair<ULong, TypeCode_ptr>, std::less<ULong> >
56 typedef std::map<const TypeCode *, ULong, std::less<const TypeCode *> >
59 TypeCode_ptr resolve_recursion() const;
61 void connect (TypeCode_ptr, Long depth = 0);
62 CORBA::ULong get_recurse_depth();
63 static CORBA::Any *convert_case_label (CORBA::TypeCode_ptr disc,
66 // begin-mico-extension
67 void disconnect (TypeCode_ptr);
68 TypeCode (const std::string &);
69 TypeCode (); // for vector<TypeCode>
72 TypeCode (const TypeCode &);
73 TypeCode (DataDecoder &);
74 TypeCode &operator= (const TypeCode &);
75 Boolean from_string (const char *);
77 static TypeCode_ptr create_basic_tc (TCKind);
78 static TypeCode_ptr create_struct_tc (const char *rep_id, const char *name,
79 const StructMemberSeq &members);
80 static TypeCode_ptr create_exception_tc (const char *rep_id,
82 const StructMemberSeq &members);
83 static TypeCode_ptr create_union_tc (const char *rep_id, const char *name,
84 TypeCode_ptr disc_type,
85 const UnionMemberSeq &members);
86 static TypeCode_ptr create_enum_tc (const char *rep_id, const char *name,
87 const EnumMemberSeq &members);
88 static TypeCode_ptr create_alias_tc (const char *rep_id, const char *name,
89 TypeCode_ptr orig_type);
90 static TypeCode_ptr create_interface_tc (const char *rep_id,
92 static TypeCode_ptr create_string_tc (ULong bound);
93 static TypeCode_ptr create_wstring_tc (ULong bound);
94 static TypeCode_ptr create_sequence_tc (ULong bound, TypeCode_ptr el_type);
95 static TypeCode_ptr create_array_tc (ULong bound, TypeCode_ptr el_type);
96 static TypeCode_ptr create_recursive_sequence_tc (ULong bound,
98 static TypeCode_ptr create_fixed_tc (UShort digits, Short scale);
99 static TypeCode_ptr create_value_tc (const char *rep_id, const char *name,
101 TypeCode_ptr concrete_base,
102 const ValueMemberSeq &members);
103 static TypeCode_ptr create_value_box_tc (const char *rep_id,
105 TypeCode_ptr boxed_type);
106 static TypeCode_ptr create_native_tc (const char *rep_id,
108 static TypeCode_ptr create_recursive_tc (const char *rep_id);
109 static TypeCode_ptr create_abstract_interface_tc (const char *rep_id,
111 static TypeCode_ptr create_local_interface_tc (const char *rep_id,
113 // end-mico-extension
115 typedef CORBA::TypeCode_Bounds Bounds;
116 typedef CORBA::TypeCode_Bounds_catch Bounds_catch;
118 typedef CORBA::TypeCode_BadKind BadKind;
119 typedef CORBA::TypeCode_BadKind_catch BadKind_catch;
121 TCKind kind () const;
122 Boolean equal (TypeCode_ptr, Boolean remove_aliases = FALSE,
123 Boolean ignore_string_bounds = FALSE) const;
124 Boolean equaltype (TypeCode_ptr, SetTC * = 0);
125 Boolean equivalent (TypeCode_ptr tc);
127 const char *id () const;
128 const char *name () const;
130 Long member_index (const Any &);
131 Long member_index (const char *);
132 ULong member_count () const;
133 const char *member_name (ULong idx) const;
134 TypeCode_ptr member_type (ULong idx) const;
135 Any *member_label (ULong idx) const;
136 TypeCode_ptr discriminator_type () const;
137 Long default_index () const;
139 ULong length () const;
141 TypeCode_ptr content_type () const;
143 UShort fixed_digits () const;
144 Short fixed_scale () const;
146 Visibility member_visibility (ULong idx) const;
147 ValueModifier type_modifier() const;
148 TypeCode_ptr concrete_base_type() const;
149 TypeCode_ptr get_compact_typecode() const;
151 ULong member_count_inherited () const;
152 const char *member_name_inherited (ULong idx) const;
153 TypeCode_ptr member_type_inherited (ULong idx) const;
154 Visibility member_visibility_inherited (ULong idx) const;
156 Long param_count () const;
157 Any *parameter (Long) const;
159 // begin-mico-extension
161 TypeCode_ptr array_type ();
162 Boolean is_constant () const;
163 TypeCode_ptr mk_constant ();
164 TypeCode_ptr unalias ();
166 void encode (DataEncoder &, MapTCPos * = NULL) const;
167 Boolean decode (DataDecoder &, MapPosTC * = NULL, ULong level = 0);
169 std::string stringify () const;
171 Boolean is_recursive_seq ();
172 Boolean is_freestanding();
173 Boolean is_freestanding( ULong depth, TypeCode_ptr tc );
176 Boolean is_base_type();
183 Boolean is_wstring();
185 Boolean is_type_code();
187 Boolean is_variable();
190 Boolean is_sequence();
192 Boolean is_valuetype();
194 Boolean is_abstract_interface();
195 // end-mico-extension
197 static TypeCode_ptr _duplicate (TypeCode_ptr);
198 static TypeCode_ptr _nil ()
203 extern void release (TypeCode_ptr);
205 //typedef ObjVar<TypeCode> TypeCode_var;
208 // begin-mico-extension
212 LNone, LArray, LSequence, LStruct, LExcept, LUnion, LValue, LValueBox
218 Long i, n, x, last_i;
220 LevelRecord (Level, TypeCode_ptr, Long n = 0, Long i = 0, Long x = 0);
221 LevelRecord (const LevelRecord &);
224 LevelRecord &operator= (const LevelRecord &);
225 Level level () const;
229 class TypeCodeChecker {
233 std::vector<LevelRecord> levelvec;
235 LevelRecord *level ();
238 Boolean leave (LevelRecord::Level, Boolean sloppy = FALSE);
239 void enter (const LevelRecord &);
240 void tc (TypeCode_ptr);
241 void override_tc (TypeCode_ptr);
244 TypeCodeChecker (TypeCode_ptr);
245 TypeCodeChecker (const TypeCodeChecker &);
246 TypeCodeChecker &operator= (const TypeCodeChecker &);
250 Boolean inside (TCKind);
251 Boolean level_finished ();
253 Boolean basic (TypeCode_ptr);
254 Boolean enumeration (Long val);
255 Boolean abstract_interface (TypeCode_ptr override);
257 Boolean union_begin ();
258 Boolean union_selection (Long idx = -1L);
259 Boolean union_end (Boolean sloppy = FALSE);
261 Boolean struct_begin ();
262 Boolean struct_end (Boolean sloppy = FALSE);
264 Boolean except_begin ();
265 Boolean except_end (Boolean sloppy = FALSE);
267 Boolean seq_begin (ULong len);
268 Boolean seq_end (Boolean sloppy = FALSE);
270 Boolean arr_begin ();
271 Boolean arr_end (Boolean sloppy = FALSE);
273 Boolean value_begin (TypeCode_ptr override = 0);
274 Boolean value_end ();
276 Boolean valuebox_begin ();
277 Boolean valuebox_end ();
280 Boolean completed () const;
281 void restart (TypeCode_ptr);
283 ULong level_count () const;
285 // end-mico-extension
288 extern MICO_EXPORT TypeCode_ptr _tc_null;
289 extern MICO_EXPORT TypeCode_ptr _tc_void;
290 extern MICO_EXPORT TypeCode_ptr _tc_short;
291 extern MICO_EXPORT TypeCode_ptr _tc_long;
292 extern MICO_EXPORT TypeCode_ptr _tc_longlong;
293 extern MICO_EXPORT TypeCode_ptr _tc_ushort;
294 extern MICO_EXPORT TypeCode_ptr _tc_ulong;
295 extern MICO_EXPORT TypeCode_ptr _tc_ulonglong;
296 extern MICO_EXPORT TypeCode_ptr _tc_float;
297 extern MICO_EXPORT TypeCode_ptr _tc_double;
298 extern MICO_EXPORT TypeCode_ptr _tc_longdouble;
299 extern MICO_EXPORT TypeCode_ptr _tc_boolean;
300 extern MICO_EXPORT TypeCode_ptr _tc_char;
301 extern MICO_EXPORT TypeCode_ptr _tc_wchar;
302 extern MICO_EXPORT TypeCode_ptr _tc_octet;
303 extern MICO_EXPORT TypeCode_ptr _tc_any;
304 extern MICO_EXPORT TypeCode_ptr _tc_TypeCode;
305 extern MICO_EXPORT TypeCode_ptr _tc_Principal;
306 extern MICO_EXPORT TypeCode_ptr _tc_Context; // extension
307 extern MICO_EXPORT TypeCode_ptr _tc_NamedValue; // extension
308 extern MICO_EXPORT TypeCode_ptr _tc_Object;
309 extern MICO_EXPORT TypeCode_ptr _tc_ValueBase;
310 extern MICO_EXPORT TypeCode_ptr _tc_AbstractBase; // extension
311 extern MICO_EXPORT TypeCode_ptr _tc_string;
312 extern MICO_EXPORT TypeCode_ptr _tc_wstring;
316 #endif // __mico_typecode_h__