Leonardus
Loading...
Searching...
No Matches
so.h
Go to the documentation of this file.
1
17#pragma once
18
19// Inc Library
20#include <string>
21
22// Inc HAA
23#include "dbc.h"
24#include "helper.h"
25#include "error.h"
26
27// Inc Medium
28#include "counter.h"
29
30
35enum class OTCode : char {
36 B,
37 F,
38 I,
39 L,
40 M,
41 N,
42 Nx,
43 O,
44 o,
45 Q,
46 R,
47
48 A,
49 Ax,
50 D,
51 K,
52 S,
53
54 X
55};
56
57
60class SO : public Counter<SO>, protected DbC {
61
64 bool exec_;
65
66
67public:
69 SO() : exec_(false) {}
70
71
74 explicit SO( bool p_exec ) : exec_(p_exec) {}
75
76
78 SO( const SO & p_other ) : Counter<SO>(), DbC(), exec_(p_other.exec_) {}
79
80
83 virtual ~SO() {}
84
85
86 SO( SO && ) = delete;
87 SO & operator=( const SO & ) = delete;
88 SO & operator=( SO && ) = delete;
89
90
91public: /* accessor */
93 bool getExec() const {
94 return exec_;
95 }
96
97
99 void setExec( bool p_exec ) {
100 exec_ = p_exec;
101 }
102
103
108 virtual size_t getSize() const {
109 return 1;
110 }
111
112
113public: /* virtual */
116 [[nodiscard]] virtual SO * dup() const = 0;
117
118
124 [[nodiscard]] virtual SO * clone() const {
125 return dup();
126 }
127
128
131 virtual std::string opequal() const = 0;
132
133
139 virtual std::string opequalequal() const {
140 return opequal();
141 }
142
143
148 virtual OTCode ot() const = 0;
149
150
153 virtual std::string type() const = 0;
154
155
166 virtual bool equal( const SO * /* unused */ ) const = 0;
167
168
174 virtual bool gt( OpError & p_ec, const SO * /* unused */ ) const {
175 p_ec = typecheck;
176 return false;
177 }
178
179
185 virtual bool ge( OpError & p_ec, const SO * /* unused */ ) const {
186 p_ec = typecheck;
187 return false;
188 }
189};
190
191
193using SOp = SO *;
194
195
198class SOcomposite : public SO {
199
200public:
201 /* Ctors */
202 using SO::SO;
203
204
205public: /* virtual */
206 std::string opequal() const override {
207 return "--nostringval--";
208 }
209
210
223 virtual size_t treeheight( size_t p_myheigth ) const {
224 return p_myheigth;
225 }
226
227};
Counter base class.
Definition counter.h:30
Design by contract interface class.
Definition dbc.h:30
Semantic Object.
Definition so.h:60
virtual bool equal(const SO *) const =0
Checks if this SO is equal to another SO.
void setExec(bool p_exec)
Setter for exec_.
Definition so.h:99
virtual std::string type() const =0
Returns a type name.
virtual SO * dup() const =0
Creates a new instance as copy following the red book definition.
virtual std::string opequalequal() const
String representation for operators '==' and 'pstack'.
Definition so.h:139
virtual ~SO()
Virtual dtor.
Definition so.h:83
virtual std::string opequal() const =0
String representation of object for operators '=', 'cvs' and 'stack'.
virtual bool ge(OpError &p_ec, const SO *) const
Greater or equal.
Definition so.h:185
virtual OTCode ot() const =0
Returns an OTCode.
bool getExec() const
Getter for exec_.
Definition so.h:93
SO(bool p_exec)
Ctor.
Definition so.h:74
SO(const SO &p_other)
Copy ctor.
Definition so.h:78
SO()
Ctor.
Definition so.h:69
virtual SO * clone() const
Creates a new instance as copy with deep cloning.
Definition so.h:124
virtual bool gt(OpError &p_ec, const SO *) const
Greater than.
Definition so.h:174
bool exec_
Flag indicating whether the SO is executable (true) or literal (false).
Definition so.h:64
virtual size_t getSize() const
Returns the size of the SO.
Definition so.h:108
Composite Semantic Object.
Definition so.h:198
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition so.h:206
virtual size_t treeheight(size_t p_myheigth) const
Tree Height.
Definition so.h:223
The class Counter.
Helpers for design by contract idioms.
Error handling.
OpError
Operator error code enum.
Definition error.h:30
@ typecheck
operator error typecheck
Definition error.h:36
Miscellaneous definitions and functions.
OTCode
OTCode - the Object Type Code.
Definition so.h:35
@ X
any SO. Is used by checks to represent any object.
@ S
SOS.
@ M
SOM.
@ A
SOA literal.
@ F
SOF.
@ N
SON literal.
@ B
SOB.
@ Nx
SON executable.
@ K
SOK.
@ Ax
SOA executable.
@ L
SOL.
@ o
SOo.
@ I
SOI.
@ R
SOR.
@ Q
SOQ.
@ O
SOO.
@ D
SOD.