Skip to content

Commit

Permalink
Apply cppcoreguidelines-avoid-non-const-global-variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rbx authored and dennisklein committed Sep 27, 2021
1 parent 1ee9d2d commit cf9b45c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fairmq/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PluginManager

static const std::string fgkLibPrefix;
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::unique_ptr<PluginServices> fPluginServices;
std::map<std::string, std::unique_ptr<Plugin>> fPlugins;
Expand Down
4 changes: 2 additions & 2 deletions fairmq/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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)
};

}
Expand Down
8 changes: 4 additions & 4 deletions fairmq/States.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace std;
namespace fair::mq
{

array<string, 16> stateNames =
const array<string, 16> stateNames =
{
{
"UNDEFINED",
Expand All @@ -38,7 +38,7 @@ array<string, 16> stateNames =
}
};

unordered_map<string, State> states =
const unordered_map<string, State> states =
{
{ "UNDEFINED", State::Undefined },
{ "OK", State::Ok },
Expand All @@ -58,7 +58,7 @@ unordered_map<string, State> states =
{ "EXITING", State::Exiting }
};

array<string, 12> transitionNames =
const array<string, 12> transitionNames =
{
{
"AUTO",
Expand All @@ -76,7 +76,7 @@ array<string, 12> transitionNames =
}
};

unordered_map<string, Transition> transitions =
const unordered_map<string, Transition> transitions =
{
{ "AUTO", Transition::Auto },
{ "INIT DEVICE", Transition::InitDevice },
Expand Down
6 changes: 3 additions & 3 deletions fairmq/Transports.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ struct TransportError : std::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},
{"zeromq", Transport::ZMQ},
{"shmem", Transport::SHM},
{"ofi", Transport::OFI}
};

static std::unordered_map<Transport, std::string> TransportNames{
static const std::unordered_map<Transport, std::string> TransportNames{
{Transport::DEFAULT, "default"},
{Transport::ZMQ, "zeromq"},
{Transport::SHM, "shmem"},
{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)
try {
Expand Down
2 changes: 1 addition & 1 deletion fairmq/shmem/Monitor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace bipc = ::boost::interprocess;

namespace
{
volatile sig_atomic_t gSignalStatus = 0;
volatile sig_atomic_t gSignalStatus = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
}

namespace fair::mq::shmem
Expand Down
4 changes: 2 additions & 2 deletions fairmq/tools/InstanceLimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ struct InstanceLimiter
}
}

static int fCount;
static int fCount; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
};

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

Expand Down

0 comments on commit cf9b45c

Please sign in to comment.