1 #ifndef __TYPECODE_HXX__
2 #define __TYPECODE_HXX__
4 #include "RefCounter.hxx"
5 #include "Exception.hxx"
30 // typedef enum DynType StreamType;
34 /*! \brief Base class for all type objects.
38 * All type objects should be a subclass of TypeCode. Some type objects,
39 * TypeCodeObjref for example, represent one individual type. Other type
40 * objects, such as TypeCodeSeq, are composite types (sequence, here)
47 class TypeCode : public RefCounter
50 TypeCode(DynType kind);
53 const char * getKindRepr() const;
55 virtual TypeCode *clone() const;
56 virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
57 virtual void destroyZippedAny(char *data) const;
58 virtual AnyPtr getOrBuildAnyFromZippedData(char *data) const;
59 virtual const char * name() const throw(Exception);
60 virtual const char * shortName() const;
61 virtual const char * id() const throw(Exception);
62 virtual const TypeCode * contentType() const throw(Exception);
63 virtual int isA(const char* repositoryId) const throw(Exception);
64 virtual int isA(const TypeCode* tc) const ;
65 virtual int isAdaptable(const TypeCode* tc) const;
66 virtual unsigned getSizeInByteOfAnyReprInSeq() const;
68 static const char *getKindRepr(DynType kind);
69 static TypeCode * interfaceTc(const char* id, const char* name);
70 static TypeCode * interfaceTc(const char* id, const char* name, const std::list<TypeCodeObjref *>& ltc);
71 static TypeCode * sequenceTc (const char* id, const char* name, TypeCode *content);
72 static TypeCode * structTc (const char* id, const char* name);
75 // --- These operators are placed here to avoid them being used externally
76 TypeCode(const TypeCode& tc);
77 TypeCode& operator=(const TypeCode& tc);
81 static const char *KIND_STR_REPR [];
85 /*! \brief Class for reference objects.
90 class TypeCodeObjref: public TypeCode
94 TypeCodeObjref(const char* repositoryId, const char* name);
96 TypeCodeObjref(const char* repositoryId, const char* name, const std::list<TypeCodeObjref *>& ltc);
98 TypeCode *clone() const;
99 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
100 void destroyZippedAny(char *data) const;
101 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
102 const char * id() const throw(Exception);
103 const char * name() const throw(Exception);
104 const char * shortName() const;
105 int isA(const char* repositoryId) const throw(Exception);
106 virtual int isA(const TypeCode* tc) const ;
107 virtual int isAdaptable(const TypeCode* tc) const;
110 TypeCodeObjref(const TypeCodeObjref& other);
113 std::string _shortName;
115 std::list<TypeCodeObjref *> _listOfBases;
119 /*! \brief Class for sequence objects.
124 class TypeCodeSeq: public TypeCode
127 TypeCodeSeq(const char* repositoryId, const char* name, const TypeCode *content);
129 TypeCode *clone() const;
130 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
131 void destroyZippedAny(char *data) const;
132 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
133 const char * id() const throw(Exception);
134 const char * name() const throw(Exception);
135 const char * shortName() const;
137 virtual const TypeCode * contentType() const throw(Exception);
138 virtual int isA(const TypeCode* tc) const ;
139 virtual int isAdaptable(const TypeCode* tc) const;
142 TypeCodeSeq(const TypeCodeSeq& tc);
145 std::string _shortName;
147 const TypeCode *_content;
150 /*! \brief Class for array objects.
155 class TypeCodeArray : public TypeCode
158 TypeCodeArray(const char* repositoryId, const char* name, const TypeCode *content, unsigned staticLgth);
159 TypeCode *clone() const;
160 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
161 void destroyZippedAny(char *data) const;
162 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
163 const char * id() const throw(Exception);
164 const char * name() const throw(Exception);
165 const char * shortName() const;
166 unsigned getStaticLgth() const;
168 virtual const TypeCode * contentType() const throw(Exception);
169 virtual int isA(const TypeCode* tc) const ;
170 virtual int isAdaptable(const TypeCode* tc) const;
171 unsigned getSizeInByteOfAnyReprInSeq() const;
174 TypeCodeArray(const TypeCodeArray& tc);
177 std::string _shortName;
179 unsigned _staticLgth;
180 const TypeCode *_content;
183 /*! \brief Class for struct type.
188 class TypeCodeStruct : public TypeCode
191 TypeCodeStruct(const char* repositoryId, const char* name);
192 TypeCode *clone() const;
193 void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
194 void destroyZippedAny(char *data) const;
195 AnyPtr getOrBuildAnyFromZippedData(char *data) const;
196 const char * id() const throw(Exception);
197 const char * name() const throw(Exception);
198 const char * shortName() const;
199 virtual int isA(const char* repositoryId) const throw(Exception);
200 virtual int isA(const TypeCode* tc) const ;
201 virtual int isAdaptable(const TypeCode* tc) const;
202 virtual void addMember(const std::string& name,TypeCode* tc);
203 int memberCount() const;
204 const char* memberName(int index) const;
205 TypeCode* memberType(int index) const;
208 TypeCodeStruct(const TypeCodeStruct& tc);
211 std::string _shortName;
213 std::vector< std::pair<std::string,TypeCode*> > _members;