@@ -0,0 +1,48 | |||||
|
1 | #include "FuzzingOperations.h" | |||
|
2 | ||||
|
3 | #include <Variable/Variable.h> | |||
|
4 | #include <Variable/VariableController.h> | |||
|
5 | ||||
|
6 | Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations") | |||
|
7 | ||||
|
8 | namespace { | |||
|
9 | ||||
|
10 | struct CreateOperation : public IFuzzingOperation { | |||
|
11 | bool canExecute(std::shared_ptr<Variable> variable) const override { | |||
|
12 | /// @todo: complete | |||
|
13 | return false; | |||
|
14 | } | |||
|
15 | ||||
|
16 | void execute(std::shared_ptr<Variable>& variable, VariableController &variableController, const Properties &properties) const override{ | |||
|
17 | /// @todo: complete | |||
|
18 | } | |||
|
19 | }; | |||
|
20 | ||||
|
21 | struct UnknownOperation : public IFuzzingOperation { | |||
|
22 | bool canExecute(std::shared_ptr<Variable> variable) const override { | |||
|
23 | Q_UNUSED(variable); | |||
|
24 | return false; | |||
|
25 | } | |||
|
26 | ||||
|
27 | void execute(std::shared_ptr<Variable>& variable, VariableController &variableController, const Properties &properties) const override{ | |||
|
28 | Q_UNUSED(variable); | |||
|
29 | Q_UNUSED(variableController); | |||
|
30 | Q_UNUSED(properties); | |||
|
31 | // Does nothing | |||
|
32 | } | |||
|
33 | }; | |||
|
34 | ||||
|
35 | } // namespace | |||
|
36 | ||||
|
37 | std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperationType type) | |||
|
38 | { | |||
|
39 | switch (type) { | |||
|
40 | case FuzzingOperationType::CREATE: | |||
|
41 | return std::make_unique<CreateOperation>(); | |||
|
42 | default: | |||
|
43 | // Default case returns unknown operation | |||
|
44 | break; | |||
|
45 | } | |||
|
46 | ||||
|
47 | return std::make_unique<UnknownOperation>(); | |||
|
48 | } |
@@ -0,0 +1,47 | |||||
|
1 | #ifndef SCIQLOP_FUZZINGOPERATIONS_H | |||
|
2 | #define SCIQLOP_FUZZINGOPERATIONS_H | |||
|
3 | ||||
|
4 | #include "FuzzingDefs.h" | |||
|
5 | ||||
|
6 | #include <memory> | |||
|
7 | #include <set> | |||
|
8 | ||||
|
9 | #include <QLoggingCategory> | |||
|
10 | #include <QMetaType> | |||
|
11 | ||||
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingOperations) | |||
|
13 | ||||
|
14 | class Variable; | |||
|
15 | class VariableController; | |||
|
16 | ||||
|
17 | /** | |||
|
18 | * Enumeration of types of existing fuzzing operations | |||
|
19 | */ | |||
|
20 | enum class FuzzingOperationType { | |||
|
21 | CREATE | |||
|
22 | }; | |||
|
23 | ||||
|
24 | /// Interface that represents an operation that can be executed during a fuzzing test | |||
|
25 | struct IFuzzingOperation { | |||
|
26 | virtual ~IFuzzingOperation() noexcept = default; | |||
|
27 | ||||
|
28 | /// Checks if the operation can be executed according to the current state of the variable passed in parameter | |||
|
29 | virtual bool canExecute(std::shared_ptr<Variable> variable) const = 0; | |||
|
30 | /// Executes the operation on the variable passed in parameter | |||
|
31 | /// @param variable the variable on which to execute the operation | |||
|
32 | /// @param variableController the controller associated to the operation | |||
|
33 | /// @param properties properties that can be used to configure the operation | |||
|
34 | /// @remarks variable is passed as a reference because, according to the operation, it can be modified (in/out parameter) | |||
|
35 | virtual void execute(std::shared_ptr<Variable> &variable, VariableController& variableController, const Properties& properties = {}) const = 0; | |||
|
36 | }; | |||
|
37 | ||||
|
38 | /// Factory of @sa IFuzzingOperation | |||
|
39 | struct FuzzingOperationFactory { | |||
|
40 | /// Creates a fuzzing operation from a type | |||
|
41 | static std::unique_ptr<IFuzzingOperation> create(FuzzingOperationType type); | |||
|
42 | }; | |||
|
43 | ||||
|
44 | using OperationsTypes = std::set<FuzzingOperationType>; | |||
|
45 | Q_DECLARE_METATYPE(OperationsTypes) | |||
|
46 | ||||
|
47 | #endif // SCIQLOP_FUZZINGOPERATIONS_H |
@@ -69,6 +69,8 tests = [ | |||||
69 | tests_sources = [ |
|
69 | tests_sources = [ | |
70 | 'tests/FuzzingDefs.h', |
|
70 | 'tests/FuzzingDefs.h', | |
71 | 'tests/FuzzingDefs.cpp', |
|
71 | 'tests/FuzzingDefs.cpp', | |
|
72 | 'tests/FuzzingOperations.h', | |||
|
73 | 'tests/FuzzingOperations.cpp', | |||
72 | ] |
|
74 | ] | |
73 |
|
75 | |||
74 | foreach unit_test : tests |
|
76 | foreach unit_test : tests |
@@ -1,4 +1,5 | |||||
1 | #include "FuzzingDefs.h" |
|
1 | #include "FuzzingDefs.h" | |
|
2 | #include "FuzzingOperations.h" | |||
2 | #include <Network/NetworkController.h> |
|
3 | #include <Network/NetworkController.h> | |
3 | #include <SqpApplication.h> |
|
4 | #include <SqpApplication.h> | |
4 | #include <Time/TimeController.h> |
|
5 | #include <Time/TimeController.h> | |
@@ -14,6 +15,11 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing") | |||||
14 |
|
15 | |||
15 | namespace { |
|
16 | namespace { | |
16 |
|
17 | |||
|
18 | // /////// // | |||
|
19 | // Aliases // | |||
|
20 | // /////// // | |||
|
21 | ||||
|
22 | using OperationsPool = std::set<std::shared_ptr<IFuzzingOperation> >; | |||
17 | // ///////// // |
|
23 | // ///////// // | |
18 | // Constants // |
|
24 | // Constants // | |
19 | // ///////// // |
|
25 | // ///////// // |
General Comments 0
You need to be logged in to leave comments.
Login now