Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.

Commit 3d23bf7

Browse files
feat: update subproject commits for json, plexa, and rationet; enhance CMakeLists and main.cpp for additional config options; add nullable property support in coco_server
1 parent 2b2d479 commit 3d23bf7

7 files changed

Lines changed: 50 additions & 8 deletions

File tree

extern/json

Submodule json updated 1 file

extern/plexa

Submodule plexa updated 1 file

extern/rationet

src/config/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ setup_sanitizers(ConfigGenerator)
1010
function(coco_config)
1111
set(options ROS_INTERFACE)
1212
set(oneValueArgs PROJ_NAME)
13-
set(multiValueArgs TYPE_FILES RULE_FILES ITEM_FILES)
14-
cmake_parse_arguments(COCO_CONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${multiValueArgs}" ${ARGN})
13+
set(multiValueArgs TYPE_FILES TYPE_FOLDERS RULE_FILES RULE_FOLDERS ITEM_FILES ITEM_FOLDERS)
14+
cmake_parse_arguments(COCO_CONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
1515

1616
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${COCO_CONFIG_PROJ_NAME}_config")
1717
file(MAKE_DIRECTORY "${GENERATED_DIR}")
@@ -38,8 +38,11 @@ function(coco_config)
3838
OUTPUT "${GENERATED_HEADER}"
3939
COMMAND $<TARGET_FILE:ConfigGenerator>
4040
-t ${COCO_CONFIG_TYPE_FILES}
41+
-tf ${COCO_CONFIG_TYPE_FOLDERS}
4142
-r ${COCO_CONFIG_RULE_FILES}
43+
-rf ${COCO_CONFIG_RULE_FOLDERS}
4244
-i ${COCO_CONFIG_ITEM_FILES}
45+
-if ${COCO_CONFIG_ITEM_FOLDERS}
4346
-o "${GENERATED_HEADER}"
4447
DEPENDS ConfigGenerator
4548
${COCO_CONFIG_TYPE_FILES}

src/config/main.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
enum ParType
55
{
66
Type,
7+
TypeFolder,
78
Rule,
9+
RuleFolder,
810
Item,
11+
ItemFolder,
912
Output
1013
};
1114

@@ -24,33 +27,63 @@ int main(int argc, char const *argv[])
2427
current_par = Type;
2528
continue;
2629
}
30+
else if (std::string(argv[i]) == "-tf")
31+
{
32+
current_par = TypeFolder;
33+
continue;
34+
}
2735
else if (std::string(argv[i]) == "-r")
2836
{
2937
current_par = Rule;
3038
continue;
3139
}
32-
else if (std::string(argv[i]) == "-o")
40+
else if (std::string(argv[i]) == "-rf")
3341
{
34-
current_par = Output;
42+
current_par = RuleFolder;
3543
continue;
3644
}
3745
else if (std::string(argv[i]) == "-i")
3846
{
3947
current_par = Item;
4048
continue;
4149
}
50+
else if (std::string(argv[i]) == "-if")
51+
{
52+
current_par = ItemFolder;
53+
continue;
54+
}
55+
else if (std::string(argv[i]) == "-o")
56+
{
57+
current_par = Output;
58+
continue;
59+
}
4260

4361
switch (current_par)
4462
{
4563
case Type:
4664
type_files.push_back(argv[i]);
4765
break;
66+
case TypeFolder:
67+
for (const auto &entry : std::filesystem::directory_iterator(argv[i]))
68+
if (entry.is_regular_file())
69+
type_files.push_back(entry.path().string());
70+
break;
4871
case Rule:
4972
rule_files.push_back(argv[i]);
5073
break;
74+
case RuleFolder:
75+
for (const auto &entry : std::filesystem::directory_iterator(argv[i]))
76+
if (entry.is_regular_file())
77+
rule_files.push_back(entry.path().string());
78+
break;
5179
case Item:
5280
items_files.push_back(argv[i]);
5381
break;
82+
case ItemFolder:
83+
for (const auto &entry : std::filesystem::directory_iterator(argv[i]))
84+
if (entry.is_regular_file())
85+
items_files.push_back(entry.path().string());
86+
break;
5487
case Output:
5588
output = argv[i];
5689
break;

src/mqtt/coco_mqtt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace coco
4646
get_coco().set_value(get_coco().get_item(msg->get_topic().substr(strlen(COCO_NAME "/data/"))), json::load(msg->to_string())); // Set value for the item based on the topic
4747
}
4848

49-
void coco_mqtt::on_connect(const std::string &cause)
49+
void coco_mqtt::on_connect([[maybe_unused]] const std::string &cause)
5050
{
5151
LOG_DEBUG("Connected to MQTT broker: " << cause);
5252

src/server/coco_server.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace coco
7171
{"description", "A property that holds integer values, with optional constraints and default values."},
7272
{"properties",
7373
{{"type", {{"type", "string"}, {"enum", {"int"}}, {"description", "The property type identifier."}}},
74+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
7475
{"multiple", {{"type", "boolean"}, {"description", "Whether this property can hold multiple values (array)."}}},
7576
{"default", {{"oneOf", std::vector<json::json>{{{"type", "integer"}}, {{"type", "array"}, {"items", {{"type", "integer"}}}}}}, {"description", "Default value(s) for this property."}}},
7677
{"min", {{"type", "integer"}, {"description", "Minimum allowed value for this property."}}},
@@ -81,6 +82,7 @@ namespace coco
8182
{"description", "A property that holds floating-point numbers, with optional constraints and default values."},
8283
{"properties",
8384
{{"type", {{"type", "string"}, {"enum", {"float"}}, {"description", "The property type identifier."}}},
85+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
8486
{"multiple", {{"type", "boolean"}, {"description", "Whether this property can hold multiple values (array)."}}},
8587
{"default", {{"oneOf", std::vector<json::json>{{{"type", "number"}}, {{"type", "array"}, {"items", {{"type", "number"}}}}}}, {"description", "Default value(s) for this property."}}},
8688
{"min", {{"type", "number"}, {"description", "Minimum allowed value for this property."}}},
@@ -91,6 +93,7 @@ namespace coco
9193
{"description", "A property that holds string values, with optional default values."},
9294
{"properties",
9395
{{"type", {{"type", "string"}, {"enum", {"string"}}, {"description", "The property type identifier."}}},
96+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
9497
{"multiple", {{"type", "boolean"}, {"description", "Whether this property can hold multiple values (array)."}}},
9598
{"default", {{"oneOf", std::vector<json::json>{{{"type", "string"}}, {{"type", "array"}, {"items", {{"type", "string"}}}}}}, {"description", "Default value(s) for this property."}}}}},
9699
{"required", std::vector<json::json>{"type"}}};
@@ -99,6 +102,7 @@ namespace coco
99102
{"description", "A property that holds predefined symbolic values from a restricted set of allowed values."},
100103
{"properties",
101104
{{"type", {{"type", "string"}, {"enum", {"symbol"}}, {"description", "The property type identifier."}}},
105+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
102106
{"values", {{"type", "array"}, {"items", {{"type", "string"}}}, {"description", "The allowed symbolic values for this property."}}},
103107
{"multiple", {{"type", "boolean"}, {"description", "Whether this property can hold multiple values (array)."}}},
104108
{"default", {{"oneOf", std::vector<json::json>{{{"type", "string"}}, {{"type", "array"}, {"items", {{"type", "string"}}}}}}, {"description", "Default value(s) for this property."}}}}},
@@ -108,6 +112,7 @@ namespace coco
108112
{"description", "A property that holds references to other items by their ID, restricted to a specific domain type."},
109113
{"properties",
110114
{{"type", {{"type", "string"}, {"enum", {"item"}}, {"description", "The property type identifier."}}},
115+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
111116
{"domain", {{"type", "string"}, {"description", "The type of objects that are allowed as values for this property."}}},
112117
{"multiple", {{"type", "boolean"}, {"description", "Whether this property can hold multiple values (array)."}}},
113118
{"default", {{"oneOf", std::vector<json::json>{{{"type", "string"}, {"pattern", "^[a-fA-F0-9]{24}$"}}, {{"type", "array"}, {"items", {{"type", "string"}, {"pattern", "^[a-fA-F0-9]{24}$"}}}}}}, {"description", "Default ID value(s) for this property."}}}}},
@@ -117,6 +122,7 @@ namespace coco
117122
{"description", "A property that holds arbitrary JSON objects conforming to a specified JSON schema."},
118123
{"properties",
119124
{{"type", {{"type", "string"}, {"enum", {"json"}}, {"description", "The property type identifier."}}},
125+
{"nullable", {{"type", "boolean"}, {"description", "Whether this property can be null."}}},
120126
{"schema", {{"type", "object"}, {"description", "The JSON schema that validates the property's value."}}},
121127
{"default", {{"type", "object"}, {"description", "Default JSON object for this property."}}}}},
122128
{"required", std::vector<json::json>{"type", "schema"}}};

0 commit comments

Comments
 (0)