##// END OF EJS Templates
Implements validation of variable's data (1)...
Alexandre Leroux -
r1231:077a4fb03e91
parent child
Show More
@@ -1,4 +1,5
1 1 #include "FuzzingValidators.h"
2 #include <Variable/Variable.h>
2 3
3 4 #include <QTest>
4 5
@@ -8,6 +9,62 Q_LOGGING_CATEGORY(LOG_FuzzingValidators, "FuzzingValidators")
8 9
9 10 namespace {
10 11
12 // ////////////// //
13 // DATA VALIDATOR //
14 // ////////////// //
15
16 /// Singleton used to validate data of a variable
17 class DataValidatorHelper {
18 public:
19 /// @return the single instance of the helper
20 static DataValidatorHelper &instance();
21 virtual ~DataValidatorHelper() noexcept = default;
22
23 virtual void validate(const VariableState &variableState) const = 0;
24 };
25
26 /**
27 * Default implementation of @sa DataValidatorHelper
28 */
29 class DefaultDataValidatorHelper : public DataValidatorHelper {
30 public:
31 void validate(const VariableState &variableState) const override
32 {
33 Q_UNUSED(variableState);
34 qCWarning(LOG_FuzzingValidators()).noquote() << "Checking variable's data... WARN: no data "
35 "verification is available for this server";
36 }
37 };
38
39 /**
40 * Implementation of @sa DataValidatorHelper for the local AMDA server
41 */
42 class LocalhostServerDataValidatorHelper : public DataValidatorHelper {
43 public:
44 void validate(const VariableState &variableState) const override
45 {
46 /// @todo: complete
47 }
48 };
49
50 /// Creates the @sa DataValidatorHelper according to the server passed in parameter
51 std::unique_ptr<DataValidatorHelper> createDataValidatorInstance(const QString &server)
52 {
53 if (server == QString{"localhost"}) {
54 return std::make_unique<LocalhostServerDataValidatorHelper>();
55 }
56 else {
57 return std::make_unique<DefaultDataValidatorHelper>();
58 }
59 }
60
61 DataValidatorHelper &DataValidatorHelper::instance()
62 {
63 // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time
64 static auto instance = createDataValidatorInstance(SCIQLOP_AMDA_SERVER);
65 return *instance;
66 }
67
11 68 // /////////////// //
12 69 // RANGE VALIDATOR //
13 70 // /////////////// //
@@ -66,7 +123,7 std::unique_ptr<IFuzzingValidator> FuzzingValidatorFactory::create(FuzzingValida
66 123 switch (type) {
67 124 case FuzzingValidatorType::DATA:
68 125 return std::make_unique<FuzzingValidator>([](const VariableState &variableState) {
69 /// @todo: complete
126 DataValidatorHelper::instance().validate(variableState);
70 127 });
71 128 case FuzzingValidatorType::RANGE:
72 129 return std::make_unique<FuzzingValidator>([](const VariableState &variableState) {
General Comments 0
You need to be logged in to leave comments. Login now