ClickHouse/dbms/Common/StatusInfo.cpp

58 lines
1.4 KiB
C++
Raw Normal View History

2020-03-16 10:32:23 +00:00
#include <Common/StatusInfo.h>
#include <Interpreters/ExternalLoader.h>
/// Available status. Add something here as you wish.
#define APPLY_FOR_STATUS(M) \
2020-03-16 13:35:22 +00:00
M(DictionaryStatus, "Dictionary Status.", DB::getStatusEnumAllPossibleValues()) \
namespace CurrentStatusInfo
{
2020-03-12 12:29:28 +00:00
#define M(NAME, DOCUMENTATION, ENUM) extern const Status NAME = __COUNTER__;
APPLY_FOR_STATUS(M)
#undef M
2020-03-12 12:29:28 +00:00
constexpr Status END = __COUNTER__;
std::mutex locks[END] {};
2020-03-12 12:09:15 +00:00
std::unordered_map<String, Int8> values[END] {};
2020-03-12 12:29:28 +00:00
const char * getName(Status event)
{
static const char * strings[] =
{
#define M(NAME, DOCUMENTATION, ENUM) #NAME,
APPLY_FOR_STATUS(M)
#undef M
};
return strings[event];
}
2020-03-12 12:29:28 +00:00
const char * getDocumentation(Status event)
{
static const char * strings[] =
{
2020-03-16 12:40:34 +00:00
#define M(NAME, DOCUMENTATION, ENUM) #DOCUMENTATION,
APPLY_FOR_STATUS(M)
#undef M
};
return strings[event];
}
2020-03-12 12:29:28 +00:00
const std::vector<std::pair<String, Int8>> & getAllPossibleValues(Status event)
{
static const std::vector<std::pair<String, Int8>> enum_values [] =
{
2020-03-16 13:35:22 +00:00
#define M(NAME, DOCUMENTATION, ENUM) ENUM,
APPLY_FOR_STATUS(M)
#undef M
};
return enum_values[event];
}
2020-03-12 12:29:28 +00:00
Status end() { return END; }
}
#undef APPLY_FOR_STATUS