Skip to content

Commit 2622046

Browse files
Building data stream data stuctures
1 parent d2b9660 commit 2622046

33 files changed

Lines changed: 1864 additions & 21 deletions

CSAPI-lib/CSAPI-lib.vcxproj

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,27 @@
132132
<ClInclude Include="APIRequest.h" />
133133
<ClInclude Include="APIResponse.h" />
134134
<ClInclude Include="ConnectedSystemsAPI.h" />
135+
<ClInclude Include="DataModels\Component\Boolean.h" />
136+
<ClInclude Include="DataModels\Component\Category.h" />
137+
<ClInclude Include="DataModels\Component\CategoryRange.h" />
138+
<ClInclude Include="DataModels\Component\Count.h" />
139+
<ClInclude Include="DataModels\Component\CountRange.h" />
140+
<ClInclude Include="DataModels\Component\DataComponent.h" />
141+
<ClInclude Include="DataModels\Component\DataComponentRegistry.h" />
142+
<ClInclude Include="DataModels\Component\DataRecord.h" />
143+
<ClInclude Include="DataModels\Component\NilValue.h" />
144+
<ClInclude Include="DataModels\Component\Quantity.h" />
145+
<ClInclude Include="DataModels\Component\QuantityRange.h" />
146+
<ClInclude Include="DataModels\Component\ScalarComponent.h" />
147+
<ClInclude Include="DataModels\Component\SimpleComponent.h" />
148+
<ClInclude Include="DataModels\Component\Text.h" />
149+
<ClInclude Include="DataModels\Component\Time.h" />
150+
<ClInclude Include="DataModels\Component\TimeRange.h" />
151+
<ClInclude Include="DataModels\Component\UnitOfMeasure.h" />
152+
<ClInclude Include="DataModels\Component\Vector.h" />
135153
<ClInclude Include="DataModels\DataStream.h" />
136154
<ClInclude Include="DataModels\Link.h" />
155+
<ClInclude Include="DataModels\ObservationSchema.h" />
137156
<ClInclude Include="DataModels\ObservedProperty.h" />
138157
<ClInclude Include="DataModels\Properties.h" />
139158
<ClInclude Include="DataModels\PropertiesBuilder.h" />
@@ -142,9 +161,11 @@
142161
<ClInclude Include="DataModels\TimeExtent.h" />
143162
<ClInclude Include="DataStreamsAPI.h" />
144163
<ClInclude Include="framework.h" />
145-
<ClInclude Include="OptionalTimePoint.h" />
164+
<ClInclude Include="Query\DataStreamsOfSystemQuery.h" />
165+
<ClInclude Include="Query\DataStreamsQuery.h" />
146166
<ClInclude Include="Query\QueryParameters.h" />
147167
<ClInclude Include="Query\SystemsQuery.h" />
168+
<ClInclude Include="RegistryInit.h" />
148169
<ClInclude Include="SystemsAPI.h" />
149170
<ClInclude Include="TimeUtils.h" />
150171
</ItemGroup>

CSAPI-lib/CSAPI-lib.vcxproj.filters

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<Filter Include="Header Files\Query">
2323
<UniqueIdentifier>{86d8700a-e917-4bd9-96e8-189e1b1a7030}</UniqueIdentifier>
2424
</Filter>
25+
<Filter Include="Header Files\DataModels\Component">
26+
<UniqueIdentifier>{f6e2dae1-77d1-44c3-b6b7-50b98264f96e}</UniqueIdentifier>
27+
</Filter>
2528
</ItemGroup>
2629
<ItemGroup>
2730
<ClInclude Include="framework.h">
@@ -36,9 +39,6 @@
3639
<ClInclude Include="ConnectedSystemsAPI.h">
3740
<Filter>Header Files</Filter>
3841
</ClInclude>
39-
<ClInclude Include="OptionalTimePoint.h">
40-
<Filter>Header Files</Filter>
41-
</ClInclude>
4242
<ClInclude Include="SystemsAPI.h">
4343
<Filter>Header Files</Filter>
4444
</ClInclude>
@@ -78,5 +78,71 @@
7878
<ClInclude Include="DataStreamsAPI.h">
7979
<Filter>Header Files</Filter>
8080
</ClInclude>
81+
<ClInclude Include="Query\DataStreamsQuery.h">
82+
<Filter>Header Files\Query</Filter>
83+
</ClInclude>
84+
<ClInclude Include="Query\DataStreamsOfSystemQuery.h">
85+
<Filter>Header Files\Query</Filter>
86+
</ClInclude>
87+
<ClInclude Include="DataModels\Component\DataComponent.h">
88+
<Filter>Header Files\DataModels\Component</Filter>
89+
</ClInclude>
90+
<ClInclude Include="DataModels\Component\Quantity.h">
91+
<Filter>Header Files\DataModels\Component</Filter>
92+
</ClInclude>
93+
<ClInclude Include="DataModels\ObservationSchema.h">
94+
<Filter>Header Files\DataModels</Filter>
95+
</ClInclude>
96+
<ClInclude Include="DataModels\Component\SimpleComponent.h">
97+
<Filter>Header Files\DataModels\Component</Filter>
98+
</ClInclude>
99+
<ClInclude Include="DataModels\Component\UnitOfMeasure.h">
100+
<Filter>Header Files\DataModels\Component</Filter>
101+
</ClInclude>
102+
<ClInclude Include="DataModels\Component\DataComponentRegistry.h">
103+
<Filter>Header Files\DataModels\Component</Filter>
104+
</ClInclude>
105+
<ClInclude Include="DataModels\Component\DataRecord.h">
106+
<Filter>Header Files\DataModels\Component</Filter>
107+
</ClInclude>
108+
<ClInclude Include="RegistryInit.h">
109+
<Filter>Header Files</Filter>
110+
</ClInclude>
111+
<ClInclude Include="DataModels\Component\NilValue.h">
112+
<Filter>Header Files\DataModels\Component</Filter>
113+
</ClInclude>
114+
<ClInclude Include="DataModels\Component\ScalarComponent.h">
115+
<Filter>Header Files\DataModels\Component</Filter>
116+
</ClInclude>
117+
<ClInclude Include="DataModels\Component\Text.h">
118+
<Filter>Header Files\DataModels\Component</Filter>
119+
</ClInclude>
120+
<ClInclude Include="DataModels\Component\Count.h">
121+
<Filter>Header Files\DataModels\Component</Filter>
122+
</ClInclude>
123+
<ClInclude Include="DataModels\Component\Time.h">
124+
<Filter>Header Files\DataModels\Component</Filter>
125+
</ClInclude>
126+
<ClInclude Include="DataModels\Component\Category.h">
127+
<Filter>Header Files\DataModels\Component</Filter>
128+
</ClInclude>
129+
<ClInclude Include="DataModels\Component\Boolean.h">
130+
<Filter>Header Files\DataModels\Component</Filter>
131+
</ClInclude>
132+
<ClInclude Include="DataModels\Component\CountRange.h">
133+
<Filter>Header Files\DataModels\Component</Filter>
134+
</ClInclude>
135+
<ClInclude Include="DataModels\Component\QuantityRange.h">
136+
<Filter>Header Files\DataModels\Component</Filter>
137+
</ClInclude>
138+
<ClInclude Include="DataModels\Component\TimeRange.h">
139+
<Filter>Header Files\DataModels\Component</Filter>
140+
</ClInclude>
141+
<ClInclude Include="DataModels\Component\CategoryRange.h">
142+
<Filter>Header Files\DataModels\Component</Filter>
143+
</ClInclude>
144+
<ClInclude Include="DataModels\Component\Vector.h">
145+
<Filter>Header Files\DataModels\Component</Filter>
146+
</ClInclude>
81147
</ItemGroup>
82148
</Project>

CSAPI-lib/ConnectedSystemsAPI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "APIRequest.h"
77
#include "SystemsAPI.h"
88
#include "DataStreamsAPI.h"
9+
#include "RegistryInit.h"
910

1011
namespace ConnectedSystemsAPI {
1112
class ConSysAPI {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <nlohmann/json.hpp>
5+
#include "ScalarComponent.h"
6+
7+
namespace ConnectedSystemsAPI {
8+
namespace DataModels {
9+
namespace Component {
10+
class Boolean;
11+
void to_json(nlohmann::ordered_json& j, const Boolean& q);
12+
13+
class Boolean : public ScalarComponent {
14+
private:
15+
std::optional<bool> value;
16+
17+
public:
18+
Boolean() = default;
19+
20+
void validate() const {
21+
ScalarComponent::validate();
22+
}
23+
24+
nlohmann::ordered_json toJson() const override {
25+
nlohmann::ordered_json j;
26+
to_json(j, *this);
27+
return j;
28+
}
29+
30+
/// <summary>Inline value(s) for the component.
31+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
32+
std::optional<int> getValue() const { return value; }
33+
/// <summary>Inline value(s) for the component.
34+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
35+
void setValue(const std::optional<int>& value) { this->value = value; }
36+
};
37+
38+
// Register with the DataComponentRegistry
39+
struct BooleanRegistrar {
40+
BooleanRegistrar() {
41+
ConnectedSystemsAPI::DataModels::Component::DataComponentRegistry::registerType(
42+
"Boolean", [](const nlohmann::json& j) {
43+
return std::make_unique<ConnectedSystemsAPI::DataModels::Component::Boolean>(j.get<ConnectedSystemsAPI::DataModels::Component::Boolean>());
44+
}
45+
);
46+
}
47+
};
48+
static BooleanRegistrar booleanRegistrar;
49+
50+
inline void from_json(const nlohmann::json& j, Boolean& v) {
51+
from_json(j, static_cast<ScalarComponent&>(v));
52+
if (j.contains("value") && j["value"].is_boolean())
53+
v.setValue(j["value"].get<bool>());
54+
else
55+
v.setValue(std::nullopt);
56+
}
57+
58+
inline void to_json(nlohmann::ordered_json& j, const Boolean& v) {
59+
to_json(j, static_cast<const ScalarComponent&>(v));
60+
if (v.getValue())
61+
j["value"] = v.getValue().value();
62+
}
63+
64+
inline std::ostream& operator<<(std::ostream& os, const Boolean& v) {
65+
nlohmann::ordered_json j;
66+
to_json(j, v);
67+
return os << j.dump(2);
68+
}
69+
}
70+
}
71+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <nlohmann/json.hpp>
5+
#include "ScalarComponent.h"
6+
7+
namespace ConnectedSystemsAPI {
8+
namespace DataModels {
9+
namespace Component {
10+
class Category;
11+
void to_json(nlohmann::ordered_json& j, const Category& q);
12+
13+
class Category : public ScalarComponent {
14+
private:
15+
std::optional<std::string> value;
16+
std::optional<std::string> codeSpace;
17+
18+
public:
19+
Category() = default;
20+
21+
void validate() const {
22+
ScalarComponent::validate();
23+
}
24+
25+
nlohmann::ordered_json toJson() const override {
26+
nlohmann::ordered_json j;
27+
to_json(j, *this);
28+
return j;
29+
}
30+
31+
/// <summary>Inline value(s) for the component.
32+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
33+
std::optional<std::string> getValue() const { return value; }
34+
/// <summary>Inline value(s) for the component.
35+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
36+
void setValue(const std::optional<std::string>& value) { this->value = value; }
37+
/// <summary>Name of the dictionary where the possible values for this component are listed and defined.</summary>
38+
std::optional<std::string> getCodeSpace() const { return codeSpace; }
39+
/// <summary>Name of the dictionary where the possible values for this component are listed and defined.</summary>
40+
void setCodeSpace(const std::optional<std::string>& codeSpace) { this->codeSpace = codeSpace; }
41+
};
42+
43+
// Register with the DataComponentRegistry
44+
struct CategoryRegistrar {
45+
CategoryRegistrar() {
46+
ConnectedSystemsAPI::DataModels::Component::DataComponentRegistry::registerType(
47+
"Category", [](const nlohmann::json& j) {
48+
return std::make_unique<ConnectedSystemsAPI::DataModels::Component::Category>(j.get<ConnectedSystemsAPI::DataModels::Component::Category>());
49+
}
50+
);
51+
}
52+
};
53+
static CategoryRegistrar categoryRegistrar;
54+
55+
inline void from_json(const nlohmann::json& j, Category& v) {
56+
from_json(j, static_cast<ScalarComponent&>(v));
57+
58+
if (j.contains("value") && j["value"].is_string())
59+
v.setValue(j["value"].get<std::string>());
60+
else
61+
v.setValue(std::nullopt);
62+
63+
if (j.contains("codeSpace") && j["codeSpace"].is_string())
64+
v.setCodeSpace(j["codeSpace"].get<std::string>());
65+
else
66+
v.setCodeSpace(std::nullopt);
67+
}
68+
69+
inline void to_json(nlohmann::ordered_json& j, const Category& v) {
70+
to_json(j, static_cast<const ScalarComponent&>(v));
71+
72+
if (v.getValue())
73+
j["value"] = v.getValue().value();
74+
75+
if (v.getCodeSpace())
76+
j["codeSpace"] = v.getCodeSpace().value();
77+
}
78+
79+
inline std::ostream& operator<<(std::ostream& os, const Category& v) {
80+
nlohmann::ordered_json j;
81+
to_json(j, v);
82+
return os << j.dump(2);
83+
}
84+
}
85+
}
86+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <nlohmann/json.hpp>
5+
#include "SimpleComponent.h"
6+
7+
namespace ConnectedSystemsAPI {
8+
namespace DataModels {
9+
namespace Component {
10+
class CategoryRange;
11+
void to_json(nlohmann::ordered_json& j, const CategoryRange& q);
12+
13+
class CategoryRange : public SimpleComponent {
14+
private:
15+
std::optional<std::vector<std::string>> value;
16+
std::optional<std::string> codeSpace;
17+
18+
public:
19+
CategoryRange() = default;
20+
21+
void validate() const {
22+
SimpleComponent::validate();
23+
}
24+
25+
nlohmann::ordered_json toJson() const override {
26+
nlohmann::ordered_json j;
27+
to_json(j, *this);
28+
return j;
29+
}
30+
31+
/// <summary>Inline value(s) for the component.
32+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
33+
std::optional<std::vector<std::string>> getValue() const { return value; }
34+
/// <summary>Inline value(s) for the component.
35+
/// This property is optional to enable structure to act as a schema for values provided separately (e.g., in a datastream)</summary>
36+
void setValue(const std::optional<std::vector<std::string>>& value) { this->value = value; }
37+
/// <summary>Name of the dictionary where the possible values for this component are listed and defined.</summary>
38+
std::optional<std::string> getCodeSpace() const { return codeSpace; }
39+
/// <summary>Name of the dictionary where the possible values for this component are listed and defined.</summary>
40+
void setCodeSpace(const std::optional<std::string>& codeSpace) { this->codeSpace = codeSpace; }
41+
};
42+
43+
// Register with the DataComponentRegistry
44+
struct CategoryRangeRegistrar {
45+
CategoryRangeRegistrar() {
46+
ConnectedSystemsAPI::DataModels::Component::DataComponentRegistry::registerType(
47+
"CategoryRange", [](const nlohmann::json& j) {
48+
return std::make_unique<ConnectedSystemsAPI::DataModels::Component::CategoryRange>(j.get<ConnectedSystemsAPI::DataModels::Component::CategoryRange>());
49+
}
50+
);
51+
}
52+
};
53+
static CategoryRangeRegistrar categoryRangeRegistrar;
54+
55+
inline void from_json(const nlohmann::json& j, CategoryRange& v) {
56+
from_json(j, static_cast<SimpleComponent&>(v));
57+
58+
if (j.contains("value") && j["value"].is_array())
59+
v.setValue(j["value"].get<std::vector<std::string>>());
60+
else
61+
v.setValue(std::nullopt);
62+
63+
if (j.contains("codeSpace") && j["codeSpace"].is_string())
64+
v.setCodeSpace(j["codeSpace"].get<std::string>());
65+
else
66+
v.setCodeSpace(std::nullopt);
67+
}
68+
69+
inline void to_json(nlohmann::ordered_json& j, const CategoryRange& v) {
70+
to_json(j, static_cast<const SimpleComponent&>(v));
71+
72+
if (v.getValue())
73+
j["value"] = v.getValue().value();
74+
75+
if (v.getCodeSpace())
76+
j["codeSpace"] = v.getCodeSpace().value();
77+
}
78+
79+
inline std::ostream& operator<<(std::ostream& os, const CategoryRange& v) {
80+
nlohmann::ordered_json j;
81+
to_json(j, v);
82+
return os << j.dump(2);
83+
}
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)