MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
MProperty Class Reference

#include <property.h>

Collaboration diagram for MProperty:
[legend]

Public Member Functions

 MProperty ()
 
 MProperty (MInt size, MString propname, MInt Solver, MString *value)
 
 MProperty (MInt size, MString propname, MInt Solver, MFloat *value)
 
 MProperty (MInt size, MString propname, MInt Solver, MInt *value)
 
 MProperty (MInt size, MString propname, MInt Solver, MBool *value)
 
 ~MProperty ()
 
MInt count ()
 
MInt doesExist ()
 
MStringasString ()
 
MIntasInt ()
 
MFloatasFloat ()
 
MBoolasBool ()
 
VariableType type ()
 
void clear ()
 
MStringasString (MInt index)
 
MIntasInt (MInt index)
 
MFloatasFloat (MInt index)
 
MBoolasBool (MInt index)
 

Public Attributes

VariableType propertyType
 
MInt elements = -1
 
MString name
 
MInt noAccesses = 0
 
MInt noOldAccesses = 0
 
MInt solverId = -1
 
MStringstringField = nullptr
 
MFloatfloatField = nullptr
 
MIntintField = nullptr
 
MBoolboolField = nullptr
 

Detailed Description

Definition at line 13 of file property.h.

Constructor & Destructor Documentation

◆ MProperty() [1/5]

MProperty::MProperty ( )

Definition at line 52 of file property.cpp.

52 {
53 // TRACE();
54 noAccesses = 0;
55 noOldAccesses = 0;
56}
MInt noAccesses
Definition: property.h:37
MInt noOldAccesses
Definition: property.h:38

◆ MProperty() [2/5]

MProperty::MProperty ( MInt  size,
MString  propname,
MInt  Solver,
MString value 
)

Definition at line 58 of file property.cpp.

58 {
59 // TRACE();
61 elements = size;
62 name = propname;
63 noAccesses = 0;
64 noOldAccesses = 0;
66 stringField = new MString[size];
67 for(MInt i = 0; i < size; i++)
68 stringField[i] = value[i];
69}
VariableType propertyType
Definition: property.h:34
MInt elements
Definition: property.h:35
MString name
Definition: property.h:36
MString * stringField
Definition: property.h:40
MInt solverId
Definition: property.h:39
Parent class of all solvers This class is the base for all solvers. I.e. all solver class (e....
Definition: solver.h:29
@ MSTRING
Definition: enums.h:269
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55

◆ MProperty() [3/5]

MProperty::MProperty ( MInt  size,
MString  propname,
MInt  Solver,
MFloat value 
)

Definition at line 71 of file property.cpp.

71 {
72 // TRACE();
74 elements = size;
75 name = propname;
76 noAccesses = 0;
77 noOldAccesses = 0;
79 floatField = new MFloat[size];
80 for(MInt i = 0; i < size; i++)
81 floatField[i] = value[i];
82}
MFloat * floatField
Definition: property.h:41
@ MFLOAT
Definition: enums.h:269
double MFloat
Definition: maiatypes.h:52

◆ MProperty() [4/5]

MProperty::MProperty ( MInt  size,
MString  propname,
MInt  Solver,
MInt value 
)

Definition at line 84 of file property.cpp.

84 {
85 // TRACE();
87 elements = size;
88 name = propname;
89 noAccesses = 0;
90 noOldAccesses = 0;
92 intField = new MInt[size];
93 for(MInt i = 0; i < size; i++)
94 intField[i] = value[i];
95}
MInt * intField
Definition: property.h:42
@ MINT
Definition: enums.h:269

◆ MProperty() [5/5]

MProperty::MProperty ( MInt  size,
MString  propname,
MInt  Solver,
MBool value 
)

Definition at line 97 of file property.cpp.

97 {
98 // TRACE();
100 elements = size;
101 name = propname;
102 noAccesses = 0;
103 noOldAccesses = 0;
105 boolField = new MBool[size];
106 for(MInt i = 0; i < size; i++)
107 boolField[i] = value[i];
108}
MBool * boolField
Definition: property.h:43
@ MBOOL
Definition: enums.h:269
bool MBool
Definition: maiatypes.h:58

◆ ~MProperty()

MProperty::~MProperty ( )

Definition at line 15 of file property.cpp.

15{ clear(); }
void clear()
Definition: property.cpp:17

Member Function Documentation

◆ asBool() [1/2]

MBool * MProperty::asBool ( )

Definition at line 144 of file property.cpp.

144 {
145 if(propertyType != MBOOL) {
146 stringstream errorMessage;
147 errorMessage << "Property " << name << " is requested as a Bool, but it is a ";
148 switch(propertyType) {
149 case MINT: {
150 errorMessage << "INT!!";
151 break;
152 }
153 case MFLOAT: {
154 errorMessage << "FLOAT!!";
155 break;
156 }
157 case MSTRING: {
158 errorMessage << "STRING!!";
159 break;
160 }
161 case MBOOL: {
162 errorMessage << "BOOL!!";
163 break;
164 }
165 default: {
166 mTerm(1, AT_, "MProperty::asBool(): switch variable 'propertyType' not matching any case");
167 }
168 }
169 mTerm(1, AT_, errorMessage.str());
170 }
171 return boolField;
172}
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

◆ asBool() [2/2]

MBool * MProperty::asBool ( MInt  index)

Definition at line 277 of file property.cpp.

277 {
278 if(propertyType != MBOOL) {
279 stringstream errorMessage;
280 errorMessage << "Property " << name << " is requested as a Bool, but it is a ";
281 switch(propertyType) {
282 case MINT: {
283 errorMessage << "INT!!";
284 break;
285 }
286 case MFLOAT: {
287 errorMessage << "FLOAT!!";
288 break;
289 }
290 case MSTRING: {
291 errorMessage << "STRING!!";
292 break;
293 }
294 case MBOOL: {
295 errorMessage << "BOOL!!";
296 break;
297 }
298 default: {
299 mTerm(1, AT_, "MProperty::asBool(): switch variable 'propertyType' not matching any case");
300 }
301 }
302 mTerm(1, AT_, errorMessage.str());
303 }
304 if(index + 1 > elements) {
305 stringstream errorMessage;
306 errorMessage << " MProperty::asBool() for property " << name << " is requested index out of range! It has "
307 << elements << " ,but it is asked for the " << index + 1 << " element! ";
308 mTerm(1, AT_, errorMessage.str());
309 }
310 // cout << " Using int property : " << name << endl;
311 // cout << " 1st value is : " << *(intField+index) << endl;
312 return (boolField + index);
313}
IdType index(const FloatType *const x, const IdType level)
Return Hilbert index for given location and level in 2D or 3D.
Definition: hilbert.h:165

◆ asFloat() [1/2]

MFloat * MProperty::asFloat ( )

Definition at line 204 of file property.cpp.

204 {
205 if(propertyType != MFLOAT && propertyType != MINT) {
206 stringstream errorMessage;
207 errorMessage << "Property " << name << " is requested as a Float, but it is a ";
208 switch(propertyType) {
209 case MINT: {
210 errorMessage << "INT!!";
211 break;
212 }
213 case MFLOAT: {
214 errorMessage << "FLOAT!!";
215 break;
216 }
217 case MSTRING: {
218 errorMessage << "STRING!!";
219 break;
220 }
221 case MBOOL: {
222 errorMessage << "BOOL!!";
223 break;
224 }
225 default: {
226 mTerm(1, AT_, "MProperty::asFloat(): switch variable 'propertyType' not matching any case");
227 }
228 }
229 mTerm(1, AT_, errorMessage.str());
230 }
231
232 // If int property is requested as float, create copy of int properties first
233 if(propertyType == MINT && floatField == nullptr) {
235 copy_n(intField, elements, floatField);
236 }
237
238 return floatField;
239}

◆ asFloat() [2/2]

MFloat * MProperty::asFloat ( MInt  index)

Definition at line 352 of file property.cpp.

352 {
353 // Check if property really is a float (or int, as getting int properties as floats is allowed)
354 if(propertyType != MFLOAT && propertyType != MINT) {
355 stringstream errorMessage;
356 errorMessage << "Property " << name << " is requested as a float, but it is a ";
357 switch(propertyType) {
358 case MINT: {
359 errorMessage << "INT!!";
360 break;
361 }
362 case MFLOAT: {
363 errorMessage << "FLOAT!!";
364 break;
365 }
366 case MSTRING: {
367 errorMessage << "STRING!!";
368 break;
369 }
370 case MBOOL: {
371 errorMessage << "BOOL!!";
372 break;
373 }
374 default: {
375 mTerm(1, AT_, "MProperty::asInt(): switch variable 'propertyType' not matching any case");
376 }
377 }
378 mTerm(1, AT_, errorMessage.str());
379 }
380
381 // Check if size is OK
382 if(index + 1 > elements) {
383 stringstream errorMessage;
384 errorMessage << " MProperty::asFloat() for property " << name << " is requested index out of range! It has "
385 << elements << " ,but it is asked for the " << index + 1 << " element! ";
386 mTerm(1, AT_, errorMessage.str());
387 }
388
389 // If int property is requested as float, create copy of int properties first
390 if(propertyType == MINT && floatField == nullptr) {
392 copy_n(intField, elements, floatField);
393 }
394
395 return (floatField + index);
396}

◆ asInt() [1/2]

MInt * MProperty::asInt ( )

Definition at line 174 of file property.cpp.

174 {
175 if(propertyType != MINT) {
176 stringstream errorMessage;
177 errorMessage << "Property " << name << " is requested as a Int, but it is a ";
178 switch(propertyType) {
179 case MINT: {
180 errorMessage << "INT!!";
181 break;
182 }
183 case MFLOAT: {
184 errorMessage << "FLOAT!!";
185 break;
186 }
187 case MSTRING: {
188 errorMessage << "STRING!!";
189 break;
190 }
191 case MBOOL: {
192 errorMessage << "BOOL!!";
193 break;
194 }
195 default: {
196 mTerm(1, AT_, "MProperty::asInt(): switch variable 'propertyType' not matching any case");
197 }
198 }
199 mTerm(1, AT_, errorMessage.str());
200 }
201 return intField;
202}

◆ asInt() [2/2]

MInt * MProperty::asInt ( MInt  index)

Definition at line 314 of file property.cpp.

314 {
315 if(propertyType != MINT) {
316 stringstream errorMessage;
317 errorMessage << "Property " << name << " is requested as a Int, but it is a ";
318 switch(propertyType) {
319 case MINT: {
320 errorMessage << "INT!!";
321 break;
322 }
323 case MFLOAT: {
324 errorMessage << "FLOAT!!";
325 break;
326 }
327 case MSTRING: {
328 errorMessage << "STRING!!";
329 break;
330 }
331 case MBOOL: {
332 errorMessage << "BOOL!!";
333 break;
334 }
335 default: {
336 mTerm(1, AT_, "MProperty::asInt(): switch variable 'propertyType' not matching any case");
337 }
338 }
339 mTerm(1, AT_, errorMessage.str());
340 }
341 if(index + 1 > elements) {
342 stringstream errorMessage;
343 errorMessage << " MProperty::asInt() for property " << name << " is requested index out of range! It has "
344 << elements << " ,but it is asked for the " << index + 1 << " element! ";
345 mTerm(1, AT_, errorMessage.str());
346 }
347 // cout << " Using int property : " << name << endl;
348 // cout << " 1st value is : " << *(intField+index) << endl;
349 return (intField + index);
350}

◆ asString() [1/2]

MString * MProperty::asString ( )

Definition at line 114 of file property.cpp.

114 {
115 if(propertyType != MSTRING) {
116 stringstream errorMessage;
117 errorMessage << "Property " << name << " is requested as a String, but it is a ";
118 switch(propertyType) {
119 case MINT: {
120 errorMessage << "INT!!";
121 break;
122 }
123 case MFLOAT: {
124 errorMessage << "FLOAT!!";
125 break;
126 }
127 case MSTRING: {
128 errorMessage << "STRING!!";
129 break;
130 }
131 case MBOOL: {
132 errorMessage << "BOOL!!";
133 break;
134 }
135 default: {
136 mTerm(1, AT_, "MProperty::asString(): switch variable 'propertyType' not matching any case");
137 }
138 }
139 mTerm(1, AT_, errorMessage.str());
140 }
141 return stringField;
142}

◆ asString() [2/2]

MString * MProperty::asString ( MInt  index)

Definition at line 241 of file property.cpp.

241 {
242 if(propertyType != MSTRING) {
243 stringstream errorMessage;
244 errorMessage << "Property " << name << " is requested as a String, but it is a ";
245 switch(propertyType) {
246 case MINT: {
247 errorMessage << "INT!!";
248 break;
249 }
250 case MFLOAT: {
251 errorMessage << "FLOAT!!";
252 break;
253 }
254 case MSTRING: {
255 errorMessage << "STRING!!";
256 break;
257 }
258 case MBOOL: {
259 errorMessage << "BOOL!!";
260 break;
261 }
262 default: {
263 mTerm(1, AT_, "MProperty::asString(): switch variable 'propertyType' not matching any case");
264 }
265 }
266 mTerm(1, AT_, errorMessage.str());
267 }
268 if(index + 1 > elements) {
269 stringstream errorMessage;
270 errorMessage << " MProperty::asString() for property " << name << " is requested index out of range! It has "
271 << elements << " ,but it is asked for the " << index + 1 << " element! " << endl;
272 mTerm(1, AT_, errorMessage.str());
273 }
274 return (stringField + index);
275}

◆ clear()

void MProperty::clear ( )

Definition at line 17 of file property.cpp.

17 {
18 TRACE();
19 switch(propertyType) {
20 case MINT: {
21 delete[] intField;
22
23 // Int properties can be requested as float, for which a copy is created. Thus also check the
24 // float field if it was allocated.
25 if(floatField != nullptr) {
26 delete[] floatField;
27 }
28
29 break;
30 }
31 case MFLOAT: {
32 delete[] floatField;
33 break;
34 }
35 case MSTRING: {
36 delete[] stringField;
37 break;
38 }
39 case MBOOL: {
40 delete[] boolField;
41 break;
42 }
43 default: {
44 stringstream errorMessage;
45 errorMessage << "MProperty::clear(): switch variable 'propertyType' with value " << propertyType
46 << " not matching any case." << endl;
47 mTerm(1, AT_, errorMessage.str());
48 }
49 }
50}

◆ count()

MInt MProperty::count ( )

Definition at line 112 of file property.cpp.

112{ return elements; }

◆ doesExist()

MInt MProperty::doesExist ( )

◆ type()

VariableType MProperty::type ( )

Definition at line 110 of file property.cpp.

110{ return propertyType; }

Member Data Documentation

◆ boolField

MBool* MProperty::boolField = nullptr

Definition at line 43 of file property.h.

◆ elements

MInt MProperty::elements = -1

Definition at line 35 of file property.h.

◆ floatField

MFloat* MProperty::floatField = nullptr

Definition at line 41 of file property.h.

◆ intField

MInt* MProperty::intField = nullptr

Definition at line 42 of file property.h.

◆ name

MString MProperty::name

Definition at line 36 of file property.h.

◆ noAccesses

MInt MProperty::noAccesses = 0

Definition at line 37 of file property.h.

◆ noOldAccesses

MInt MProperty::noOldAccesses = 0

Definition at line 38 of file property.h.

◆ propertyType

VariableType MProperty::propertyType

Definition at line 34 of file property.h.

◆ solverId

MInt MProperty::solverId = -1

Definition at line 39 of file property.h.

◆ stringField

MString* MProperty::stringField = nullptr

Definition at line 40 of file property.h.


The documentation for this class was generated from the following files: