Skip to main content

validators Namespace

Definition

namespace simaai::neat::validators { ... }

Functions Index

std::shared_ptr< Contract >NonEmptyPipeline ()

Ensures NodeGroup is not empty. More...

std::shared_ptr< Contract >NoNullNodes ()

Ensures there are no null node pointers. More...

std::shared_ptr< Contract >SinkLastForRun (std::string sink_kind="Output")

Ensures Output exists and is last when ctx.mode == Run. More...

std::shared_ptr< Contract >RtspRequiresSource (std::string source_kind="StillImageInput")

Ensures an RTSP source node exists when ctx.mode == Rtsp. More...

ContractRegistryDefaultRegistry ()

Reasonable default set of builder-level contracts. More...

Functions

DefaultRegistry()

ContractRegistry simaai::neat::validators::DefaultRegistry ()
inline

Reasonable default set of builder-level contracts.

Keep this purely structural (no GStreamer).

Definition at line 180 of file Validators.h.

182 reg.add(NonEmptyPipeline());
183 reg.add(NoNullNodes());
184 reg.add(SinkLastForRun());
186 return reg;
187}

NonEmptyPipeline()

std::shared_ptr<Contract> simaai::neat::validators::NonEmptyPipeline ()
inline

Ensures NodeGroup is not empty.

Definition at line 29 of file Validators.h.

29inline std::shared_ptr<Contract> NonEmptyPipeline() {
30 class C final : public Contract {
31 public:
32 std::string id() const override {
33 return "NonEmptyPipeline";
34 }
35 std::string description() const override {
36 return "Pipeline must contain at least one node.";
37 }
38
39 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
40 ValidationReport& r) const override {
41 (void)ctx;
42 if (nodes.empty()) {
43 r.add_error(id(), "EMPTY_PIPELINE", "No nodes were added to the pipeline.");
44 }
45 }
46 };
47 return std::make_shared<C>();
48}

NoNullNodes()

std::shared_ptr<Contract> simaai::neat::validators::NoNullNodes ()
inline

Ensures there are no null node pointers.

Definition at line 53 of file Validators.h.

53inline std::shared_ptr<Contract> NoNullNodes() {
54 class C final : public Contract {
55 public:
56 std::string id() const override {
57 return "NoNullNodes";
58 }
59 std::string description() const override {
60 return "All nodes must be non-null shared_ptr.";
61 }
62
63 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
64 ValidationReport& r) const override {
65 (void)ctx;
66 const auto& v = nodes.nodes();
67 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
68 if (!v[static_cast<std::size_t>(i)]) {
69 r.add_error(id(), "NULL_NODE", "Null node pointer in NodeGroup.", i);
70 }
71 }
72 }
73 };
74 return std::make_shared<C>();
75}

RtspRequiresSource()

std::shared_ptr<Contract> simaai::neat::validators::RtspRequiresSource (std::string source_kind="StillImageInput")
inline

Ensures an RTSP source node exists when ctx.mode == Rtsp.

Builder-level: we only check presence of StillImageInput (or another configured kind).

Definition at line 133 of file Validators.h.

133inline std::shared_ptr<Contract> RtspRequiresSource(std::string source_kind = "StillImageInput") {
134 class C final : public Contract {
135 public:
136 explicit C(std::string k) : src_kind_(std::move(k)) {}
137 std::string id() const override {
138 return "RtspRequiresSource";
139 }
140 std::string description() const override {
141 return "RTSP mode requires a server-side source node (e.g., StillImageInput).";
142 }
143
144 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
145 ValidationReport& r) const override {
147 return;
148
149 const auto& v = nodes.nodes();
150 bool found = false;
151 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
152 const auto& n = v[static_cast<std::size_t>(i)];
153 if (n && n->kind() == src_kind_) {
154 found = true;
155 break;
156 }
157 }
158
159 if (!found) {
160 r.add_error(id(), "RTSP_SOURCE_MISSING",
161 "RTSP mode requires a node of kind \"" + src_kind_ + "\".", -1, src_kind_, "");
162 }
163 }
164
165 private:
166 std::string src_kind_;
167 };
168 return std::make_shared<C>(std::move(source_kind));
169}

SinkLastForRun()

std::shared_ptr<Contract> simaai::neat::validators::SinkLastForRun (std::string sink_kind="Output")
inline

Ensures Output exists and is last when ctx.mode == Run.

This is the builder-level version of the "sink last" contract described in the architecture.

Definition at line 82 of file Validators.h.

82inline std::shared_ptr<Contract> SinkLastForRun(std::string sink_kind = "Output") {
83 class C final : public Contract {
84 public:
85 explicit C(std::string kind) : sink_kind_(std::move(kind)) {}
86 std::string id() const override {
87 return "SinkLastForRun";
88 }
89 std::string description() const override {
90 return "When running, the pipeline must end with the terminal appsink node.";
91 }
92
93 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
94 ValidationReport& r) const override {
96 return;
97 const auto& v = nodes.nodes();
98 if (v.empty())
99 return;
100
101 int last_idx = static_cast<int>(v.size()) - 1;
102 const auto& last = v.back();
103 const std::string last_kind = last ? last->kind() : "";
104
105 // Require sink kind last.
106 if (!last || last_kind != sink_kind_) {
107 r.add_error(id(), "SINK_NOT_LAST", "Last node must be " + sink_kind_ + " for run().",
108 last_idx, last_kind, last ? last->user_label() : "");
109 }
110
111 // Disallow additional sinks earlier (best-effort sanity).
112 for (int i = 0; i < last_idx; ++i) {
113 const auto& n = v[static_cast<std::size_t>(i)];
114 if (n && n->kind() == sink_kind_) {
115 r.add_error(id(), "MULTIPLE_SINKS",
116 "Found " + sink_kind_ + " before the end of the pipeline.", i, n->kind(),
117 n->user_label());
118 }
119 }
120 }
121
122 private:
123 std::string sink_kind_;
124 };
125 return std::make_shared<C>(std::move(sink_kind));
126}

The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.