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