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
14 * Szabo, Janos Zoltan – initial implementation
16 ******************************************************************************/
17 #ifndef _Asn_Object0_HH
18 #define _Asn_Object0_HH
20 #include "../Setting.hh"
25 using namespace Common;
34 class Ref_defd_simple;
40 * Abstract parent for defined references.
42 class Ref_defd : public Common::Ref_simple {
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);
56 * Class to represent simple defined references to entities.
58 class Ref_defd_simple : public Ref_defd {
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);
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();
85 * \defgroup AST_Object Object
101 class OSEV_objcollctr;
106 * Class to represent ObjectClass.
108 class ObjectClass : public Governor {
109 protected: // OC_defn and OC_refd need access to their parent
110 ObjectClass(const ObjectClass& p) : Governor(p) {}
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;
123 * ObjectSetElement visitor
125 class OSE_Visitor : public Node {
126 protected: // Three derived classes need access to loc
129 /** Copy constructor not implemented */
130 OSE_Visitor(const OSE_Visitor& p);
131 /** Assignment not implemented */
132 OSE_Visitor& operator=(const OSE_Visitor& p);
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;
141 * Something that can be in an ObjectSet.
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;
155 * Class to represent Object.
157 class Object : public Governed, public OS_Element {
158 protected: // Obj_defn and Obj_refd need access
159 ObjectClass *my_governor;
162 Object(const Object& p)
163 : Governed(p), OS_Element(p), my_governor(0),
164 is_erroneous(p.is_erroneous) {}
166 Object& operator=(const Object& p);
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);
190 * Class to represent ObjectSet.
192 class ObjectSet : public GovdSet {
193 protected: // OS_defn and OS_refd need access
194 ObjectClass *my_governor;
196 ObjectSet(const ObjectSet& p) : GovdSet(p), my_governor(0)
199 ObjectSet& operator=(const ObjectSet& p);
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;
213 /** @} end of AST_Object group */
215 /** @} end of AST group */
219 #endif // _Asn_Object0_HH