Apply cppcoreguidelines-avoid-non-const-global-variables

This commit is contained in:
Alexey Rybalchenko 2021-09-13 12:51:11 +02:00 committed by Dennis Klein
parent 1ee9d2d222
commit cf9b45cd75
6 changed files with 13 additions and 13 deletions

View File

@ -115,7 +115,7 @@ class PluginManager
static const std::string fgkLibPrefix; static const std::string fgkLibPrefix;
std::vector<boost::filesystem::path> fSearchPaths; std::vector<boost::filesystem::path> fSearchPaths;
static std::vector<boost::dll::shared_library> fgDLLKeepAlive; static std::vector<boost::dll::shared_library> fgDLLKeepAlive; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
std::map<std::string, std::function<PluginFactory>> fPluginFactories; std::map<std::string, std::function<PluginFactory>> fPluginFactories;
std::unique_ptr<PluginServices> fPluginServices; std::unique_ptr<PluginServices> fPluginServices;
std::map<std::string, std::unique_ptr<Plugin>> fPlugins; std::map<std::string, std::unique_ptr<Plugin>> fPlugins;

View File

@ -65,9 +65,9 @@ class PropertyHelper
} }
} }
static std::unordered_map<std::type_index, void(*)(const fair::mq::EventManager&, const std::string&, const Property&)> fEventEmitters; static std::unordered_map<std::type_index, void(*)(const fair::mq::EventManager&, const std::string&, const Property&)> fEventEmitters; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
private: private:
static std::unordered_map<std::type_index, std::function<std::pair<std::string, std::string>(const Property&)>> fTypeInfos; static std::unordered_map<std::type_index, std::function<std::pair<std::string, std::string>(const Property&)>> fTypeInfos; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
}; };
} }

View File

@ -16,7 +16,7 @@ using namespace std;
namespace fair::mq namespace fair::mq
{ {
array<string, 16> stateNames = const array<string, 16> stateNames =
{ {
{ {
"UNDEFINED", "UNDEFINED",
@ -38,7 +38,7 @@ array<string, 16> stateNames =
} }
}; };
unordered_map<string, State> states = const unordered_map<string, State> states =
{ {
{ "UNDEFINED", State::Undefined }, { "UNDEFINED", State::Undefined },
{ "OK", State::Ok }, { "OK", State::Ok },
@ -58,7 +58,7 @@ unordered_map<string, State> states =
{ "EXITING", State::Exiting } { "EXITING", State::Exiting }
}; };
array<string, 12> transitionNames = const array<string, 12> transitionNames =
{ {
{ {
"AUTO", "AUTO",
@ -76,7 +76,7 @@ array<string, 12> transitionNames =
} }
}; };
unordered_map<string, Transition> transitions = const unordered_map<string, Transition> transitions =
{ {
{ "AUTO", Transition::Auto }, { "AUTO", Transition::Auto },
{ "INIT DEVICE", Transition::InitDevice }, { "INIT DEVICE", Transition::InitDevice },

View File

@ -31,21 +31,21 @@ struct TransportError : std::runtime_error
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
}; };
static std::unordered_map<std::string, Transport> TransportTypes{ static const std::unordered_map<std::string, Transport> TransportTypes{
{"default", Transport::DEFAULT}, {"default", Transport::DEFAULT},
{"zeromq", Transport::ZMQ}, {"zeromq", Transport::ZMQ},
{"shmem", Transport::SHM}, {"shmem", Transport::SHM},
{"ofi", Transport::OFI} {"ofi", Transport::OFI}
}; };
static std::unordered_map<Transport, std::string> TransportNames{ static const std::unordered_map<Transport, std::string> TransportNames{
{Transport::DEFAULT, "default"}, {Transport::DEFAULT, "default"},
{Transport::ZMQ, "zeromq"}, {Transport::ZMQ, "zeromq"},
{Transport::SHM, "shmem"}, {Transport::SHM, "shmem"},
{Transport::OFI, "ofi"} {Transport::OFI, "ofi"}
}; };
inline std::string TransportName(Transport transport) { return TransportNames[transport]; } inline std::string TransportName(Transport transport) { return TransportNames.at(transport); }
inline Transport TransportType(const std::string& transport) inline Transport TransportType(const std::string& transport)
try { try {

View File

@ -43,7 +43,7 @@ namespace bipc = ::boost::interprocess;
namespace namespace
{ {
volatile sig_atomic_t gSignalStatus = 0; volatile sig_atomic_t gSignalStatus = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} }
namespace fair::mq::shmem namespace fair::mq::shmem

View File

@ -43,11 +43,11 @@ struct InstanceLimiter
} }
} }
static int fCount; static int fCount; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
}; };
template<typename Tag, int Max> template<typename Tag, int Max>
int InstanceLimiter<Tag, Max>::fCount(0); int InstanceLimiter<Tag, Max>::fCount(0); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace fair::mq::tools } // namespace fair::mq::tools