#pragma once #include "yql_panic.h" #include #include namespace NYql { template class TResetableSettingBase { protected: using TSet = S; using TReset = R; public: void Set(const TSet& value) { Value.ConstructInPlace(value); } void Reset(const TReset& value) { Value.ConstructInPlace(value); } bool Defined() const { return Value.Defined(); } explicit operator bool() const { return Defined(); } bool IsSet() const { YQL_ENSURE(Defined()); return Value->index() == 0; } const TSet& GetValueSet() const { YQL_ENSURE(IsSet()); return std::get(*Value); } const TReset& GetValueReset() const { YQL_ENSURE(!IsSet()); return std::get(*Value); } private: TMaybe> Value; }; template class TResetableSetting: public TResetableSettingBase { }; template class TResetableSetting: public TResetableSettingBase { private: const TNothing& GetValueReset() const; public: void Reset() { TResetableSettingBase::Reset(Nothing()); } }; }