Skip to content

Commit 73c702f

Browse files
committed
fix(R): Replace enum class with struct for R
1 parent 47bdec0 commit 73c702f

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/io/Config.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ void Config::adaptDefaults()
271271
inline const char* flowModelToString(FlowModel flowModel)
272272
{
273273
switch (flowModel) {
274-
case FlowModel::undirected:
275-
return "undirected";
276274
case FlowModel::directed:
277275
return "directed";
278276
case FlowModel::undirdir:
@@ -281,6 +279,9 @@ inline const char* flowModelToString(FlowModel flowModel)
281279
return "outdirdir";
282280
case FlowModel::rawdir:
283281
return "rawdir";
282+
case FlowModel::undirected:
283+
default:
284+
return "undirected";
284285
}
285286
}
286287

src/io/Config.h

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,35 @@
4242

4343
namespace infomap {
4444

45-
enum class FlowModel {
46-
undirected,
47-
directed,
48-
undirdir,
49-
outdirdir,
50-
rawdir,
45+
struct FlowModel {
46+
static constexpr int undirected = 0;
47+
static constexpr int directed = 1;
48+
static constexpr int undirdir = 2;
49+
static constexpr int outdirdir = 3;
50+
static constexpr int rawdir = 4;
51+
52+
int value = 0;
53+
54+
FlowModel(int val) : value(val) {}
55+
FlowModel& operator=(int val) { value = val; return *this; }
56+
57+
58+
operator int&() { return value; }
59+
operator int() const { return value; }
5160
};
5261

5362
std::ostream& operator<<(std::ostream& out, FlowModel f);
5463

55-
enum class OptimizationLevel {
56-
FullCoarseTune,
57-
FastCoarseTune,
58-
NoTune,
59-
NoAggregationNoTune
64+
struct OptimizationLevel {
65+
static constexpr int FullCoarseTune = 0;
66+
static constexpr int FastCoarseTune = 1;
67+
static constexpr int NoTune = 2;
68+
static constexpr int NoAggregationNoTune = 3;
69+
70+
int value = 0;
71+
72+
operator int&() { return value; }
73+
operator int() const { return value; }
6074
};
6175

6276
struct Config {

0 commit comments

Comments
 (0)