-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathAbstractParameterInterface.h
More file actions
596 lines (526 loc) · 20.4 KB
/
Copy pathAbstractParameterInterface.h
File metadata and controls
596 lines (526 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//-----------------------------------------------------------------------------
// File: AbstractParametersInterface.h
//-----------------------------------------------------------------------------
// Project: Kactus2
// Author: Mikko Teuho
// Date: 22.09.2020
//
// Description:
// Abstraction for parameter interfaces.
//-----------------------------------------------------------------------------
#ifndef ABSTRACTPARAMETERSINTERFACE_H
#define ABSTRACTPARAMETERSINTERFACE_H
#include <KactusAPI/KactusAPIGlobal.h>
#include "ParameterizableInterface.h"
#include "NameGroupInterface.h"
class Choice;
class Component;
class Parameter;
class ParameterValidator;
//-----------------------------------------------------------------------------
//! Interface for editing parameters.
//-----------------------------------------------------------------------------
class KACTUS2_API AbstractParameterInterface: public ParameterizableInterface, public NameGroupInterface
{
public:
/*!
* The constructor.
*
* @param [in] validator Validator for parameters.
* @param [in] expressionParser Parser for expressions.
* @param [in] expressionFormatter Formatter for expressions.
*/
AbstractParameterInterface(QSharedPointer<ParameterValidator> validator,
QSharedPointer<ExpressionParser> expressionParser,
QSharedPointer<ExpressionFormatter> expressionFormatter);
/*!
* The destructor.
*/
virtual ~AbstractParameterInterface() = default;
/*!
* Set available choices.
*
* @param [in] newChoices The new choices.
*/
void setChoices(QSharedPointer<QList<QSharedPointer<Choice> > > newChoices);
/*!
* Set a new name for the selected item.
*
* @param [in] currentName Name of the selected item.
* @param [in] newName New name for the item.
*
* @return True, if successful, false otherwise.
*/
virtual bool setName(std::string const& currentName, std::string const& newName) override final;
/*!
* Calculate all the references to the selected ID in the selected item.
*
* @param [in] itemName Name of the selected item.
* @param [in] valueID The selected ID.
*
* @return Number of references to the selected ID in the selected item.
*/
virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override final;
/*!
* Get the expressions in the selected parameters.
*
* @param [in] parameterNames Names of the selected parameters.
*
* @return Expressions in the selected parameters.
*/
std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> parameterNames) const;
/*!
* Validates the contained items.
*
* @return True, if all the items are valid, false otherwise.
*/
virtual bool validateItems() const override final;
/*!
* Check if the selected item has a valid name.
*
* @param [in] itemName Name of the selected item.
*
* @return True, if the name is valid, false otherwise.
*/
virtual bool itemHasValidName(std::string const& itemName) const override final;
/*!
* Get the display name of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Name of the selected parameter.
*/
std::string getDisplayName(std::string const& parameterName) const;
/*!
* Set the display name of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newDisplayName New display name for the parameter.
*
* @return True, if successful, false otherwise.
*/
bool setDisplayName(std::string const& parameterName, std::string const& newDisplayName);
/*!
* Get the type of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Type of the selected parameter.
*/
std::string getType(std::string const& parameterName) const;
/*!
* Set the type of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newType New type for the parameter.
*
* @return True, if successful, false otherwise.
*/
bool setType(std::string const& parameterName, std::string const& newType);
/*!
* Get the calculated bit width left value of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] baseNumber Base for displaying the value.
*
* @return Calculated bit width left value of the selected parameter.
*/
std::string getBitWidthLeftValue(std::string const& parameterName, int const& baseNumber = 0) const;
/*!
* Get the formatted bit width left expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Formatted bit width left expression of the selected parameter.
*/
std::string getBitWidthLeftFormattedExpression(std::string const& parameterName) const;
/*!
* Get the bit width left expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Bit width left expression of the selected parameter.
*/
std::string getBitWidthLeftExpression(std::string const& parameterName) const;
/*!
* Set a new bit width left value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newBitWidthLeft New bit width left value.
*
* @return True, if successful, false otherwise.
*/
bool setBitWidthLeft(std::string const& parameterName, std::string const& newBitWidthLeft);
/*!
* Get the calculated bit width right value of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] baseNumber Base for displaying the value.
*
* @return Calculated bit width right value of the selected port.
*/
std::string getBitWidthRightValue(std::string const& parameterName, int const& baseNumber = 0) const;
/*!
* Get the formatted bit width right expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Formatted bit width right expression of the selected parameter.
*/
std::string getBitWidthRightFormattedExpression(std::string const& parameterName) const;
/*!
* Get the bit width right expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Bit width right expression of the selected parameter.
*/
std::string getBitWidthRightExpression(std::string const& parameterName) const;
/*!
* Set a new bit width right value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newBitWidthRight New bit width right value.
*
* @return True, if successful, false otherwise.
*/
bool setBitWidthRight(std::string const& parameterName, std::string const& newBitWidthRight);
/*!
* Get the minimum value the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Minimum value of the selected parameter.
*/
std::string getMinimum(std::string const& parameterName) const;
/*!
* Set the minimum value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newMinimum New minimum value of the parameter.
*
* @return True, if successful, false otherwise.
*/
bool setMinimum(std::string const& parameterName, std::string const& newMinimum);
/*!
* Get the maximum value the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Maximum value of the selected parameter.
*/
std::string getMaximum(std::string const& parameterName) const;
/*!
* Set the maximum value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newMaximum New maximum value of the parameter.
*
* @return True, if successful, false otherwise.
*/
bool setMaximum(std::string const& parameterName, std::string const& newMaximum);
/*!
* Get the choice reference of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Choice reference of the selected parameter.
*/
std::string getChoice(std::string const& parameterName) const;
/*!
* Set the choice reference for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newChoice The new choice reference.
*
* @return True, if successful, false otherwise.
*/
bool setChoice(std::string const& parameterName, std::string const& newChoice);
/*!
* Get the calculated value of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] baseNumber Base for displaying the value.
*
* @return Calculated value of the selected port.
*/
std::string getValue(std::string const& parameterName, int const& baseNumber = 0) const;
/*!
* Get the formatted value expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Formatted value expression of the selected parameter.
*/
std::string getValueFormattedExpression(std::string const& parameterName) const;
/*!
* Get the value expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Value expression of the selected parameter.
*/
std::string getValueExpression(std::string const& parameterName) const;
/*!
* Set a new value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newValue New value.
*
* @return True, if successful, false otherwise.
*/
bool setValue(std::string const& parameterName, std::string const& newValue);
/*!
* Get the resolve of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Resolve of the selected parameter.
*/
std::string getResolve(std::string const& parameterName) const;
/*!
* Set a resolve for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newResolve New resolve.
*
* @return True, if successful, false otherwise.
*/
bool setResolve(std::string const& parameterName, std::string const& newResolve);
/*!
* Get the calculated array left value of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] baseNumber Base for displaying the value.
*
* @return Calculated array left value of the selected port.
*/
std::string getArrayLeftValue(std::string const& parameterName, int const& baseNumber = 0) const;
/*!
* Get the formatted array left expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Formatted array left expression of the selected parameter.
*/
std::string getArrayLeftFormattedExpression(std::string const& parameterName) const;
/*!
* Get the array left expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Array left expression of the selected parameter.
*/
std::string getArrayLeftExpression(std::string const& parameterName) const;
/*!
* Set a new array left value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newArrayLeft New array left value.
*
* @return True, if successful, false otherwise.
*/
bool setArrayLeft(std::string const& parameterName, std::string const& newArrayLeft);
/*!
* Get the calculated array right value of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] baseNumber Base for displaying the value.
*
* @return Calculated array right value of the selected port.
*/
std::string getArrayRightValue(std::string const& parameterName, int const& baseNumber = 0) const;
/*!
* Get the formatted array right expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Formatted array right expression of the selected parameter.
*/
std::string getArrayRightFormattedExpression(std::string const& parameterName) const;
/*!
* Get the array right expression of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Array right expression of the selected parameter.
*/
std::string getArrayRightExpression(std::string const& parameterName) const;
/*!
* Set a new array right value for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newArrayRight New array right value.
*
* @return True, if successful, false otherwise.
*/
bool setArrayRight(std::string const& parameterName, std::string const& newArrayRight);
/*!
* Get the ID of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return ID of the selected parameter.
*/
std::string getID(std::string const& parameterName) const;
/*!
* Set a new ID for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newID New ID.
*
* @return True, if successful, false otherwise.
*/
bool setID(std::string const& parameterName, std::string const& newID);
/*!
* Get the usage count of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return Usage count of the selected parameter.
*/
int getUsageCount(std::string const& parameterName) const;
/*!
* Set a new usage count for the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
* @param [in] newUsageCount New usage count.
*
* @return True, if successful, false otherwise.
*/
bool setUsageCount(std::string const& parameterName, int const& newUsageCount);
/*!
* Increase the usage count of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return True, if successful, false otherwise.
*/
bool increaseUsageCount(std::string const& parameterName);
/*!
* Decrease the usage count of the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return True, if successful, false otherwise.
*/
bool reduceUsageCount(std::string const& parameterName);
/*!
* Check if the selected parameter has a valid type.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the type is valid, false otherwise.
*/
bool hasValidType(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid bit width.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the bit width is valid, false otherwise.
*/
bool hasValidBitWidth(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid minimum.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the minimum is valid, false otherwise.
*/
bool hasValidMinimum(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid maximum.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the maximum is valid, false otherwise.
*/
bool hasValidMaximum(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid choice.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the choice is valid, false otherwise.
*/
bool hasValidChoice(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid value.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the value is valid, false otherwise.
*/
bool hasValidValue(std::string const& parameterName) const;
/*!
* Check if the selected parameter has a valid resolve.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the resolve is valid, false otherwise.
*/
bool hasValidResolve(std::string const& parameterName) const;
/*!
* Check if the selected parameter has valid array values.
*
* @param [in] parameterName New of the selected parameter.
*
* @return True, if the array values are valid, false otherwise.
*/
bool hasValidArrayValues(std::string const& parameterName) const;
//! No copying. No assignment.
AbstractParameterInterface(const AbstractParameterInterface& other) = delete;
AbstractParameterInterface& operator=(const AbstractParameterInterface& other) = delete;
private:
/*!
* Get the selected parameter.
*
* @param [in] parameterName Name of the selected parameter.
*
* @return The selected parameter.
*/
virtual QSharedPointer<Parameter> getParameter(std::string const& parameterName) const = 0;
/*!
* Evaluate the value of the selected parameter.
*
* @param [in] parameter The selected parameter.
*
* @return Evaluated value of the selected parameter.
*/
QString evaluateValue(QSharedPointer<Parameter> parameter) const;
/*!
* Find the selected choice.
*
* @param [in] choiceName Name of the selected choice.
*
* @return The selected choice.
*/
QSharedPointer<Choice> findChoice(QString const& choiceName) const;
/*!
* Changes the array value to match the current choice.
*
* @param [in] choice The currently active choice.
* @param [in] arrayValue The array value to be changed.
*
* @return Array whose values have been changed to match the currently selected choice.
*/
QString matchArrayValuesToSelectedChoice(QSharedPointer<Choice> choice, QString const& arrayValue) const;
/*!
* Finds a human-readable value to display for a given enumeration.
*
* @param [in] choice The choice whose enumeration to find.
* @param [in] enumerationValue The value used to search the enumeration.
*
* @return A value for the enumeration to display.
*/
QString findDisplayValueForEnumeration(QSharedPointer<Choice> choice, QString const& enumerationValue) const;
//-----------------------------------------------------------------------------
// Data.
//-----------------------------------------------------------------------------
//! List of available choices.
QSharedPointer<QList<QSharedPointer<Choice> > > choices_ = nullptr;
//! The parameter validator.
QSharedPointer<ParameterValidator> parameterValidator_ = nullptr;
};
#endif // ABSTRACTPARAMETERSINTERFACE_H