Merge github.com:eclipse/titan.core
[deliverable/titan.core.git] / compiler2 / asn1 / Object0.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Forstner, Matyas
11 * Gecse, Roland
12 * Raduly, Csaba
13 * Szabados, Kristof
14 * Szabo, Janos Zoltan – initial implementation
15 *
16 ******************************************************************************/
17 #ifndef _Asn_Object0_HH
18 #define _Asn_Object0_HH
19
20 #include "../Setting.hh"
21 #include "../Code.hh"
22
23 namespace Asn {
24
25 using namespace Common;
26
27 /**
28 * \addtogroup AST
29 *
30 * @{
31 */
32
33 class Ref_defd;
34 class Ref_defd_simple;
35
36 // not defined here
37 class Assignment;
38
39 /**
40 * Abstract parent for defined references.
41 */
42 class Ref_defd : public Common::Ref_simple {
43 public:
44 virtual Ref_defd* clone() const =0;
45 virtual Ref_defd_simple* get_ref_defd_simple() =0;
46 virtual const Identifier* get_modid();
47 virtual const Identifier* get_id();
48 /** Appends error messages when necessary. */
49 virtual bool refers_to_st(Setting::settingtype_t p_st,
50 ReferenceChain* refch=0);
51 virtual void generate_code (expression_struct_t *expr);
52 virtual void generate_code_const_ref(expression_struct_t *expr);
53 };
54
55 /**
56 * Class to represent simple defined references to entities.
57 */
58 class Ref_defd_simple : public Ref_defd {
59 private:
60 Identifier *modid;
61 Identifier *id;
62
63 /** The copy constructor. For clone() only. */
64 Ref_defd_simple(const Ref_defd_simple& p);
65 /** Assignment disabled */
66 Ref_defd_simple& operator=(const Ref_defd_simple& p);
67 public:
68 /** Constructs a new reference. \a p_modid can be 0. */
69 Ref_defd_simple(Identifier *p_modid, Identifier *p_id);
70 virtual ~Ref_defd_simple();
71 /** Virtual constructor. */
72 virtual Ref_defd_simple* clone() const
73 {return new Ref_defd_simple(*this);}
74 virtual Ref_defd_simple* get_ref_defd_simple() {return this;}
75 /** Returns the \a modid, or 0 if not present. */
76 virtual const Identifier* get_modid() {return modid;}
77 /** Returns the \a id. */
78 virtual const Identifier* get_id() {return id;}
79 /** Returns the referenced assigment. Appends an error message
80 * and returns 0 when it cannot resolve the reference */
81 Assignment* get_refd_ass();
82 };
83
84 /**
85 * \defgroup AST_Object Object
86 *
87 * @{
88 */
89
90 class ObjectClass;
91 class OSE_Visitor;
92 class OS_Element;
93 class Object;
94 class ObjectSet;
95
96 // not defined here
97 class OC_defn;
98 class OCS_root;
99 class FieldSpecs;
100 class Obj_defn;
101 class OSEV_objcollctr;
102 class OS_defn;
103 class OS_refd;
104
105 /**
106 * Class to represent ObjectClass.
107 */
108 class ObjectClass : public Governor {
109 protected: // OC_defn and OC_refd need access to their parent
110 ObjectClass(const ObjectClass& p) : Governor(p) {}
111 public:
112 ObjectClass() : Governor(S_OC) {}
113 virtual ObjectClass* clone() const =0;
114 virtual OC_defn* get_refd_last(ReferenceChain *refch=0) =0;
115 virtual void chk_this_obj(Object *obj) =0;
116 virtual OCS_root* get_ocs() =0;
117 virtual FieldSpecs* get_fss() =0;
118 virtual void generate_code(output_struct *target) =0;
119 virtual void dump(unsigned level) const =0;
120 };
121
122 /**
123 * ObjectSetElement visitor
124 */
125 class OSE_Visitor : public Node {
126 protected: // Three derived classes need access to loc
127 const Location *loc;
128 private:
129 /** Copy constructor not implemented */
130 OSE_Visitor(const OSE_Visitor& p);
131 /** Assignment not implemented */
132 OSE_Visitor& operator=(const OSE_Visitor& p);
133 public:
134 OSE_Visitor(const Location *p_loc) : Node(), loc(p_loc) {}
135 virtual OSE_Visitor* clone() const;
136 virtual void visit_Object(Object& p) =0;
137 virtual void visit_OS_refd(OS_refd& p) =0;
138 };
139
140 /**
141 * Something that can be in an ObjectSet.
142 */
143 class OS_Element {
144 public:
145 virtual ~OS_Element();
146 virtual OS_Element *clone_ose() const = 0;
147 virtual void accept(OSE_Visitor& v) = 0;
148 virtual void set_fullname_ose(const string& p_fullname) = 0;
149 virtual void set_genname_ose(const string& p_prefix,
150 const string& p_suffix) = 0;
151 virtual void set_my_scope_ose(Scope *p_scope) = 0;
152 };
153
154 /**
155 * Class to represent Object.
156 */
157 class Object : public Governed, public OS_Element {
158 protected: // Obj_defn and Obj_refd need access
159 ObjectClass *my_governor;
160 bool is_erroneous;
161
162 Object(const Object& p)
163 : Governed(p), OS_Element(p), my_governor(0),
164 is_erroneous(p.is_erroneous) {}
165 private:
166 Object& operator=(const Object& p);
167 public:
168 Object() : Governed(S_O), OS_Element(), my_governor(0),
169 is_erroneous(false) {}
170 virtual Object *clone() const = 0;
171 /** Sets the governor ObjectClass. */
172 virtual void set_my_governor(ObjectClass *p_gov);
173 /** Gets the governor ObjectClass. */
174 virtual ObjectClass* get_my_governor() const {return my_governor;}
175 virtual Obj_defn* get_refd_last(ReferenceChain *refch=0) =0;
176 virtual void chk() =0;
177 void set_is_erroneous() {is_erroneous=true;}
178 bool get_is_erroneous() {return is_erroneous;}
179 virtual size_t get_nof_elems() {return 1;}
180 virtual void accept(OSE_Visitor& v) {v.visit_Object(*this);}
181 virtual void generate_code(output_struct *target) = 0;
182 virtual OS_Element *clone_ose() const;
183 virtual void set_fullname_ose(const string& p_fullname);
184 virtual void set_genname_ose(const string& p_prefix,
185 const string& p_suffix);
186 virtual void set_my_scope_ose(Scope *p_scope);
187 };
188
189 /**
190 * Class to represent ObjectSet.
191 */
192 class ObjectSet : public GovdSet {
193 protected: // OS_defn and OS_refd need access
194 ObjectClass *my_governor;
195
196 ObjectSet(const ObjectSet& p) : GovdSet(p), my_governor(0)
197 {}
198 private:
199 ObjectSet& operator=(const ObjectSet& p);
200 public:
201 ObjectSet() : GovdSet(S_OS), my_governor(0) {}
202 virtual ObjectSet* clone() const =0;
203 virtual void set_my_governor(ObjectClass *p_gov);
204 virtual ObjectClass* get_my_governor() const {return my_governor;}
205 virtual OS_defn* get_refd_last(ReferenceChain *refch=0) =0;
206 virtual size_t get_nof_objs() =0;
207 virtual Object* get_obj_byIndex(size_t p_i) =0;
208 virtual void accept(OSEV_objcollctr& v) =0;
209 virtual void chk() =0;
210 virtual void generate_code(output_struct *target) =0;
211 };
212
213 /** @} end of AST_Object group */
214
215 /** @} end of AST group */
216
217 } // namespace Asn
218
219 #endif // _Asn_Object0_HH
This page took 0.034429 seconds and 5 git commands to generate.