FuzzingOperations.h
50 lines
| 1.9 KiB
| text/x-c
|
CLexer
|
r1202 | #ifndef SCIQLOP_FUZZINGOPERATIONS_H | ||
#define SCIQLOP_FUZZINGOPERATIONS_H | ||||
#include "FuzzingDefs.h" | ||||
#include <memory> | ||||
#include <set> | ||||
#include <QLoggingCategory> | ||||
#include <QMetaType> | ||||
Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingOperations) | ||||
class VariableController; | ||||
/** | ||||
* Enumeration of types of existing fuzzing operations | ||||
*/ | ||||
|
r1225 | enum class FuzzingOperationType { CREATE, DELETE, PAN_LEFT, PAN_RIGHT, ZOOM_IN, ZOOM_OUT }; | ||
|
r1202 | |||
/// Interface that represents an operation that can be executed during a fuzzing test | ||||
struct IFuzzingOperation { | ||||
virtual ~IFuzzingOperation() noexcept = default; | ||||
|
r1236 | /// Checks if the operation can be executed according to the current test's state for the | ||
/// variable passed in parameter | ||||
virtual bool canExecute(VariableId variableId, const FuzzingState &fuzzingState) const = 0; | ||||
/// Executes the operation on the variable for which its identifier is passed in parameter | ||||
/// @param variableId the variable identifier | ||||
/// @param fuzzingState the current test's state on which to find the variable and execute the | ||||
/// operation | ||||
|
r1202 | /// @param variableController the controller associated to the operation | ||
/// @param properties properties that can be used to configure the operation | ||||
|
r1236 | /// @remarks fuzzingState is passed as a reference because, according to the operation, it can | ||
/// be modified (in/out parameter) | ||||
virtual void execute(VariableId variableId, FuzzingState &fuzzingState, | ||||
VariableController &variableController, | ||||
|
r1211 | const Properties &properties = {}) const = 0; | ||
|
r1202 | }; | ||
/// Factory of @sa IFuzzingOperation | ||||
struct FuzzingOperationFactory { | ||||
/// Creates a fuzzing operation from a type | ||||
static std::unique_ptr<IFuzzingOperation> create(FuzzingOperationType type); | ||||
}; | ||||
|
r1216 | using WeightedOperationsTypes = std::map<FuzzingOperationType, double>; | ||
Q_DECLARE_METATYPE(WeightedOperationsTypes) | ||||
|
r1202 | |||
#endif // SCIQLOP_FUZZINGOPERATIONS_H | ||||