Salome HOME
PR: merge from BR_DATACONV_PR tag "mergeto_trunk_25oct06"
[modules/yacs.git] / src / engine / TypeCode.hxx
1 #ifndef __TYPECODE_HXX__
2 #define __TYPECODE_HXX__
3
4 //#include <Python.h> // here, to avoid warning: "_POSIX_C_SOURCE" redefined
5
6 #include "Exception.hxx"
7
8 #include <string>
9 #include <list>
10
11 namespace YACS
12 {
13   namespace ENGINE
14   {
15
16     typedef enum
17       {
18         None     = 0,
19         Double   = 1,
20         Int      = 2,
21         String   = 3,
22         Bool     = 4,
23         Objref   = 5,
24         Sequence = 6
25       } DynType;
26
27 //     typedef enum DynType StreamType;
28
29     class TypeCode_objref;
30
31     class TypeCode
32     {
33     public:
34       TypeCode(DynType kind);
35       virtual ~TypeCode();
36
37       DynType kind() const;
38
39       virtual const char * name()       const throw(Exception);
40       virtual const char * id()         const throw(Exception);
41       virtual TypeCode * content_type() const throw(Exception);
42       virtual int is_a(const char* repositoryId);
43       virtual int is_a(TypeCode* tc);
44
45       static TypeCode * interface_tc(const char* id, const char* name);
46       static TypeCode * interface_tc(const char* id, const char* name, std::list<TypeCode_objref *> ltc);
47       static TypeCode * sequence_tc (const char* id, const char* name, TypeCode *content);
48
49     protected:
50       // --- These operators are placed here to avoid them being used externally
51       TypeCode(const TypeCode& tc);
52       TypeCode& operator=(const TypeCode& tc);
53       TypeCode() {}
54
55       DynType _kind;
56     };
57
58
59     class TypeCode_objref: public TypeCode
60     {
61     public:
62       TypeCode_objref(const char* repositoryId, const char* name);
63
64       TypeCode_objref(const char* repositoryId, const char* name, std::list<TypeCode_objref *> ltc);
65       virtual ~TypeCode_objref();
66
67       const char * id() const   throw(Exception);
68       const char * name() const throw(Exception);
69       int is_a(const char* repositoryId) throw(Exception);
70       virtual int is_a(TypeCode* tc) throw(Exception);
71
72     private:
73       TypeCode_objref() {}
74
75       std::string _name;
76       std::string _repoId;
77       std::list<TypeCode_objref *> _listOfBases;
78     };
79
80
81     class TypeCode_seq: public TypeCode
82     {
83     public:
84       TypeCode_seq(const char* repositoryId, const char* name, TypeCode *content);
85       virtual ~TypeCode_seq();
86
87       const char * id()   const throw(Exception);
88       const char * name() const throw(Exception);
89
90       virtual TypeCode * content_type() const throw(Exception);
91       virtual int is_a(TypeCode* tc);
92
93     private:
94       TypeCode_seq() {}
95
96       std::string _name;
97       std::string _repoId;
98       TypeCode  * _content;
99     };
100   }
101 }
102 #endif