#include #include #include namespace Coordination { static const std::unordered_set VALID_OPERATIONS = { static_cast(OpNum::Close), static_cast(OpNum::Error), static_cast(OpNum::Create), static_cast(OpNum::Remove), static_cast(OpNum::Exists), static_cast(OpNum::Get), static_cast(OpNum::Set), static_cast(OpNum::SimpleList), static_cast(OpNum::Sync), static_cast(OpNum::Heartbeat), static_cast(OpNum::List), static_cast(OpNum::Check), static_cast(OpNum::Multi), static_cast(OpNum::Auth), static_cast(OpNum::SessionID), static_cast(OpNum::SetACL), static_cast(OpNum::GetACL), }; std::string toString(OpNum op_num) { switch (op_num) { case OpNum::Close: return "Close"; case OpNum::Error: return "Error"; case OpNum::Create: return "Create"; case OpNum::Remove: return "Remove"; case OpNum::Exists: return "Exists"; case OpNum::Get: return "Get"; case OpNum::Set: return "Set"; case OpNum::SimpleList: return "SimpleList"; case OpNum::List: return "List"; case OpNum::Check: return "Check"; case OpNum::Multi: return "Multi"; case OpNum::Sync: return "Sync"; case OpNum::Heartbeat: return "Heartbeat"; case OpNum::Auth: return "Auth"; case OpNum::SessionID: return "SessionID"; case OpNum::SetACL: return "SetACL"; case OpNum::GetACL: return "GetACL"; } int32_t raw_op = static_cast(op_num); throw Exception("Operation " + std::to_string(raw_op) + " is unknown", Error::ZUNIMPLEMENTED); } OpNum getOpNum(int32_t raw_op_num) { if (!VALID_OPERATIONS.contains(raw_op_num)) throw Exception("Operation " + std::to_string(raw_op_num) + " is unknown", Error::ZUNIMPLEMENTED); return static_cast(raw_op_num); } }