2 #include "TypeCode.hxx"
4 using namespace YACS::ENGINE;
9 TypeCode::TypeCode(DynType kind)
18 DynType TypeCode::kind() const
23 const char * TypeCode::name() const throw(Exception)
25 throw Exception("No name");
29 const char * TypeCode::id() const throw(Exception)
44 int TypeCode::is_a(const char* id)
46 throw Exception("Not implemented for this type");
49 int TypeCode::is_a(TypeCode* tc)
51 if(_kind == tc->kind()) return 1;
55 TypeCode * TypeCode::content_type() const throw(Exception)
57 throw Exception("No content type");
61 * static factory of object reference types
64 TypeCode * TypeCode::interface_tc(const char* id,
67 return new TypeCode_objref(id, name);
70 TypeCode * TypeCode::interface_tc(const char* id,
72 list<TypeCode_objref *> ltc)
74 return new TypeCode_objref(id, name,ltc);
79 * static factory of sequence types
82 TypeCode * TypeCode::sequence_tc(const char* id,
86 return new TypeCode_seq(id, name,content);
90 // --- TypeCode_objref
93 TypeCode_objref::TypeCode_objref(const char* repositoryId,
97 _repoId = repositoryId;
102 TypeCode_objref::~TypeCode_objref()
106 const char * TypeCode_objref::id() const throw(Exception)
108 return _repoId.c_str();
111 const char * TypeCode_objref::name() const throw(Exception)
113 return _name.c_str();
116 TypeCode_objref::TypeCode_objref(const char* repositoryId,
118 list<TypeCode_objref *> ltc)
121 _repoId = repositoryId;
126 int TypeCode_objref::is_a(const char* id) throw(Exception)
128 if(_repoId.c_str() == id)return 1;
129 list<TypeCode_objref *>::iterator iter;
130 for(iter=_listOfBases.begin();iter != _listOfBases.end(); iter++)
132 if ((*iter)->is_a(id)) return 1;
137 int TypeCode_objref::is_a(TypeCode* tc) throw(Exception)
139 return is_a(tc->id());
145 TypeCode_seq::TypeCode_seq(const char* repositoryId,
150 _repoId = repositoryId;
155 TypeCode_seq::~TypeCode_seq()
159 const char * TypeCode_seq::id() const throw(Exception)
161 return _repoId.c_str();
164 const char * TypeCode_seq::name() const throw(Exception)
166 return _name.c_str();
169 TypeCode * TypeCode_seq::content_type() const throw(Exception)
174 int TypeCode_seq::is_a(TypeCode* tc)
176 if(_kind == tc->kind())
178 if(_content->is_a(tc->content_type())) return 1;