diff --git a/plugins/amda/meson.build b/plugins/amda/meson.build index 1531a2f..51775b0 100644 --- a/plugins/amda/meson.build +++ b/plugins/amda/meson.build @@ -69,6 +69,8 @@ tests = [ tests_sources = [ 'tests/FuzzingDefs.h', 'tests/FuzzingDefs.cpp', + 'tests/FuzzingOperations.h', + 'tests/FuzzingOperations.cpp', ] foreach unit_test : tests diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp new file mode 100644 index 0000000..6a1ef4a --- /dev/null +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -0,0 +1,48 @@ +#include "FuzzingOperations.h" + +#include +#include + +Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations") + +namespace { + +struct CreateOperation : public IFuzzingOperation { + bool canExecute(std::shared_ptr variable) const override { + /// @todo: complete + return false; + } + + void execute(std::shared_ptr& variable, VariableController &variableController, const Properties &properties) const override{ + /// @todo: complete + } +}; + +struct UnknownOperation : public IFuzzingOperation { + bool canExecute(std::shared_ptr variable) const override { + Q_UNUSED(variable); + return false; + } + + void execute(std::shared_ptr& variable, VariableController &variableController, const Properties &properties) const override{ + Q_UNUSED(variable); + Q_UNUSED(variableController); + Q_UNUSED(properties); + // Does nothing + } +}; + +} // namespace + +std::unique_ptr FuzzingOperationFactory::create(FuzzingOperationType type) +{ + switch (type) { + case FuzzingOperationType::CREATE: + return std::make_unique(); + default: + // Default case returns unknown operation + break; + } + + return std::make_unique(); +} diff --git a/plugins/amda/tests/FuzzingOperations.h b/plugins/amda/tests/FuzzingOperations.h new file mode 100644 index 0000000..6626eee --- /dev/null +++ b/plugins/amda/tests/FuzzingOperations.h @@ -0,0 +1,47 @@ +#ifndef SCIQLOP_FUZZINGOPERATIONS_H +#define SCIQLOP_FUZZINGOPERATIONS_H + +#include "FuzzingDefs.h" + +#include +#include + +#include +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingOperations) + +class Variable; +class VariableController; + +/** + * Enumeration of types of existing fuzzing operations + */ +enum class FuzzingOperationType { + CREATE +}; + +/// Interface that represents an operation that can be executed during a fuzzing test +struct IFuzzingOperation { + virtual ~IFuzzingOperation() noexcept = default; + + /// Checks if the operation can be executed according to the current state of the variable passed in parameter + virtual bool canExecute(std::shared_ptr variable) const = 0; + /// Executes the operation on the variable passed in parameter + /// @param variable the variable on which to execute the operation + /// @param variableController the controller associated to the operation + /// @param properties properties that can be used to configure the operation + /// @remarks variable is passed as a reference because, according to the operation, it can be modified (in/out parameter) + virtual void execute(std::shared_ptr &variable, VariableController& variableController, const Properties& properties = {}) const = 0; +}; + +/// Factory of @sa IFuzzingOperation +struct FuzzingOperationFactory { + /// Creates a fuzzing operation from a type + static std::unique_ptr create(FuzzingOperationType type); +}; + +using OperationsTypes = std::set; +Q_DECLARE_METATYPE(OperationsTypes) + +#endif // SCIQLOP_FUZZINGOPERATIONS_H diff --git a/plugins/amda/tests/TestAmdaFuzzing.cpp b/plugins/amda/tests/TestAmdaFuzzing.cpp index 50fa408..57a183a 100644 --- a/plugins/amda/tests/TestAmdaFuzzing.cpp +++ b/plugins/amda/tests/TestAmdaFuzzing.cpp @@ -1,4 +1,5 @@ #include "FuzzingDefs.h" +#include "FuzzingOperations.h" #include #include #include