Skip to content

Commit

Permalink
opt: use enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
rtgiskard committed Oct 6, 2024
1 parent 276e60d commit 406bced
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace mtrx {

using SView = std::string_view;

enum Operation {
OP_RUN,
OP_TEST,
OP_DUMP,
OP_UDP2P,
enum class Operation {
RUN,
TEST,
DUMP,
UDP2P,
};

class Config {
Expand All @@ -30,7 +30,7 @@ class Config {
std::string version;

utils::LogSettings log;
udp2p::Config udp2p;
udp2p::Config udp2p;

public:
bool load(SView path);
Expand Down
4 changes: 2 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ int main(int argc, char ** argv) {
return 2;

switch (config.op) {
case mtrx::OP_DUMP:
case mtrx::Operation::DUMP:
config.dump();
break;
case mtrx::OP_UDP2P: {
case mtrx::Operation::UDP2P: {
auto udp2p = mtrx::udp2p::Udp2p(config.udp2p);
udp2p.run();
break;
Expand Down
6 changes: 3 additions & 3 deletions src/udp2p/udp2p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ void Udp2p::run() {
logger_->info("run mode: {}", static_cast<int>(config_.mode));

switch (config_.mode) {
case Udp2p_Mode::UDP2P_MODE_PEER:
case Udp2p_Mode::PEER:
peer_ptr_ = std::make_unique<Peer>(ctx_);
break;
case Udp2p_Mode::UDP2P_MODE_SERVER:
case Udp2p_Mode::SERVER:
server_ptr_ = std::make_unique<Server>(ctx_);
break;
case Udp2p_Mode::UDP2P_MODE_HYBRID:
case Udp2p_Mode::HYBRID:
peer_ptr_ = std::make_unique<Peer>(ctx_);
server_ptr_ = std::make_unique<Server>(ctx_);
break;
Expand Down
6 changes: 3 additions & 3 deletions src/udp2p/udp2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace mtrx {
namespace udp2p {

enum class Udp2p_Mode {
UDP2P_MODE_PEER, // peer only
UDP2P_MODE_SERVER, // server only
UDP2P_MODE_HYBRID // peer + server
PEER, // peer only
SERVER, // server only
HYBRID // peer + server
};

class Config {
Expand Down

0 comments on commit 406bced

Please sign in to comment.