Skip to content

Commit 21e8f53

Browse files
committed
gndtruth_extractor: Replace enumconfable by fable
1 parent baae3c3 commit 21e8f53

6 files changed

+49
-105
lines changed

plugins/gndtruth_extractor/src/enumconfable.hpp

-73
This file was deleted.

plugins/gndtruth_extractor/src/gndtruth_extractor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class GndTruthExtractor : public Controller {
179179
void start(const Sync& sync) override {
180180
Controller::start(sync);
181181
auto log = this->logger();
182-
serializer_ = makeGndTruthSerializer(config_.output_type.value, log);
182+
serializer_ = makeGndTruthSerializer(config_.output_type, log);
183183
open_file();
184184
}
185185

plugins/gndtruth_extractor/src/gndtruth_extractor.hpp

+12-28
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* \file gndtruth_extractor.hpp
2020
*/
2121

22-
#include "enumconfable.hpp" // for EnumConfable
22+
#include <cloe/core.hpp> // for Confable, Schema
2323

2424
namespace cloe {
2525
enum class OutputTypeEnum {
@@ -33,25 +33,23 @@ enum class OutputTypeEnum {
3333
MSGPACK,
3434
};
3535

36-
typedef EnumStringConfable<OutputTypeEnum> OutputType;
37-
3836
// clang-format off
39-
IMPLEMENT_ENUMSTRINGMAP(cloe::OutputTypeEnum)
40-
(cloe::OutputTypeEnum::JSON_BZIP2 , "json.bz2" )
41-
(cloe::OutputTypeEnum::JSON_GZIP , "json.gz" )
42-
(cloe::OutputTypeEnum::JSON_ZIP , "json.zip" )
43-
(cloe::OutputTypeEnum::JSON , "json" )
44-
(cloe::OutputTypeEnum::MSGPACK_BZIP2, "msgpack.bz2" )
45-
(cloe::OutputTypeEnum::MSGPACK_GZIP , "msgpack.gz" )
46-
(cloe::OutputTypeEnum::MSGPACK_ZIP , "msgpack.zip" )
47-
(cloe::OutputTypeEnum::MSGPACK , "msgpack" )
48-
;
37+
ENUM_SERIALIZATION(OutputTypeEnum, ({
38+
{cloe::OutputTypeEnum::JSON_BZIP2 , "json.bz2" },
39+
{cloe::OutputTypeEnum::JSON_GZIP , "json.gz" },
40+
{cloe::OutputTypeEnum::JSON_ZIP , "json.zip" },
41+
{cloe::OutputTypeEnum::JSON , "json" },
42+
{cloe::OutputTypeEnum::MSGPACK_BZIP2, "msgpack.bz2" },
43+
{cloe::OutputTypeEnum::MSGPACK_GZIP , "msgpack.gz" },
44+
{cloe::OutputTypeEnum::MSGPACK_ZIP , "msgpack.zip" },
45+
{cloe::OutputTypeEnum::MSGPACK , "msgpack" },
46+
}))
4947
// clang-format on
5048

5149
namespace controller {
5250
struct GndTruthExtractorConfiguration : public Confable {
5351
std::string output_file;
54-
OutputType output_type;
52+
cloe::OutputTypeEnum output_type{cloe::OutputTypeEnum::JSON_GZIP};
5553
std::vector<std::string> components;
5654

5755
CONFABLE_SCHEMA(GndTruthExtractorConfiguration) {
@@ -61,20 +59,6 @@ struct GndTruthExtractorConfiguration : public Confable {
6159
{"output_type", Schema(&output_type, "type of output file to write")},
6260
};
6361
}
64-
65-
void to_json(Json& j) const override {
66-
j = Json{
67-
{"components", components},
68-
{"output_file", output_file},
69-
{"output_type", output_type},
70-
};
71-
}
72-
73-
// TODO(ben): Is this override still necessary?
74-
virtual void from_conf(const Conf& conf) override {
75-
Confable::from_conf(conf);
76-
conf.try_from("output_type", &output_type);
77-
}
7862
};
7963

8064
} // namespace controller

plugins/gndtruth_extractor/src/gndtruth_extractor_test.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,18 @@ TEST(gndtruth_extractor, gndtruth_extractor_schema) {
4444
"type": "string"
4545
},
4646
"output_type": {
47-
"description": "type of output file to write"
47+
"description": "type of output file to write",
48+
"enum": [
49+
"json.bz2",
50+
"json.gz",
51+
"json.zip",
52+
"json",
53+
"msgpack.bz2",
54+
"msgpack.gz",
55+
"msgpack.zip",
56+
"msgpack"
57+
],
58+
"type": "string"
4859
}
4960
},
5061
"type": "object"

tests/test_engine_json_schema.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,18 @@
251251
"type": "string"
252252
},
253253
"output_type": {
254-
"description": "type of output file to write"
254+
"description": "type of output file to write",
255+
"enum": [
256+
"json.bz2",
257+
"json.gz",
258+
"json.zip",
259+
"json",
260+
"msgpack.bz2",
261+
"msgpack.gz",
262+
"msgpack.zip",
263+
"msgpack"
264+
],
265+
"type": "string"
255266
}
256267
},
257268
"type": "object"

tests/test_engine_json_schema_with_vtd.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,18 @@
251251
"type": "string"
252252
},
253253
"output_type": {
254-
"description": "type of output file to write"
254+
"description": "type of output file to write",
255+
"enum": [
256+
"json.bz2",
257+
"json.gz",
258+
"json.zip",
259+
"json",
260+
"msgpack.bz2",
261+
"msgpack.gz",
262+
"msgpack.zip",
263+
"msgpack"
264+
],
265+
"type": "string"
255266
}
256267
},
257268
"type": "object"

0 commit comments

Comments
 (0)