VariableStates.h
71 lines
| 1.8 KiB
| text/x-c
|
CLexer
Alexandre Leroux
|
r806 | #ifndef SCIQLOP_VARIABLESTATES_H | ||
#define SCIQLOP_VARIABLESTATES_H | ||||
#include "CoreGlobal.h" | ||||
#include <Common/MetaTypes.h> | ||||
#include <memory> | ||||
#include <tuple> | ||||
#include <QVariantMap> | ||||
using StateData = QVariantMap; | ||||
SCIQLOP_REGISTER_META_TYPE(STATEDATA_REGISTRY, StateData) | ||||
/** | ||||
* @brief The IVariableState class is the representation interface of a state in which a variable | ||||
* may be. It proposes different methods to represent the variable according to its current state | ||||
* @sa Variable | ||||
*/ | ||||
struct SCIQLOP_CORE_EXPORT IVariableState { | ||||
virtual ~IVariableState() noexcept = default; | ||||
virtual std::unique_ptr<IVariableState> clone() const = 0; | ||||
/// @return the data associated with the state | ||||
virtual StateData data() const = 0; | ||||
}; | ||||
/// Default implementation of @sa IVariableState | ||||
class AbstractVariableState : public IVariableState { | ||||
public: | ||||
/// @sa IVariableState::data() | ||||
StateData data() const override; | ||||
protected: | ||||
explicit AbstractVariableState(StateData data); | ||||
private: | ||||
StateData m_Data; | ||||
}; | ||||
Alexandre Leroux
|
r807 | /** | ||
* State when a variable is fully loaded (i.e. the last request on the variable has been | ||||
* successfully completed) | ||||
*/ | ||||
class LoadedState : public AbstractVariableState { | ||||
public: | ||||
explicit LoadedState(); | ||||
std::unique_ptr<IVariableState> clone() const override; | ||||
}; | ||||
/** | ||||
* State when a variable is loading (i.e. there's pending requests for the variable) | ||||
*/ | ||||
class LoadingState : public AbstractVariableState { | ||||
public: | ||||
explicit LoadingState(); | ||||
std::unique_ptr<IVariableState> clone() const override; | ||||
}; | ||||
/** | ||||
* State when a variable is canceled (i.e. the last request on the variable has been canceled) | ||||
*/ | ||||
class CanceledState : public AbstractVariableState { | ||||
public: | ||||
explicit CanceledState(); | ||||
std::unique_ptr<IVariableState> clone() const override; | ||||
}; | ||||
Alexandre Leroux
|
r806 | #endif // SCIQLOP_VARIABLESTATES_H | ||