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 in the NodeGroup. More...

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

Ensures the configured sink kind 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.

Bundles NonEmptyPipeline, NoNullNodes, SinkLastForRun, and RtspRequiresSource into a fresh registry. Keep this purely structural (no GStreamer); domain-specific contracts should be added on top.

Returns

New ContractRegistry populated with the default contracts.

Definition at line 217 of file Validators.h.

219 reg.add(NonEmptyPipeline());
220 reg.add(NoNullNodes());
221 reg.add(SinkLastForRun());
223 return reg;
224}

NonEmptyPipeline()

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

Ensures NodeGroup is not empty.

Issues EMPTY_PIPELINE error when validated against an empty NodeGroup.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 43 of file Validators.h.

43inline std::shared_ptr<Contract> NonEmptyPipeline() {
44 class C final : public Contract {
45 public:
46 std::string id() const override {
47 return "NonEmptyPipeline";
48 }
49 std::string description() const override {
50 return "Pipeline must contain at least one node.";
51 }
52
53 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
54 ValidationReport& r) const override {
55 (void)ctx;
56 if (nodes.empty()) {
57 r.add_error(id(), "EMPTY_PIPELINE", "No nodes were added to the pipeline.");
58 }
59 }
60 };
61 return std::make_shared<C>();
62}

NoNullNodes()

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

Ensures there are no null node pointers in the NodeGroup.

Issues a NULL_NODE error per offending index.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 72 of file Validators.h.

72inline std::shared_ptr<Contract> NoNullNodes() {
73 class C final : public Contract {
74 public:
75 std::string id() const override {
76 return "NoNullNodes";
77 }
78 std::string description() const override {
79 return "All nodes must be non-null shared_ptr.";
80 }
81
82 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
83 ValidationReport& r) const override {
84 (void)ctx;
85 const auto& v = nodes.nodes();
86 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
87 if (!v[static_cast<std::size_t>(i)]) {
88 r.add_error(id(), "NULL_NODE", "Null node pointer in NodeGroup.", i);
89 }
90 }
91 }
92 };
93 return std::make_shared<C>();
94}

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). Issues RTSP_SOURCE_MISSING if no Node of the expected kind is found in the NodeGroup.

Parameters
source_kind

The Node kind expected to act as the RTSP source.

Returns

Shared pointer to a fresh Contract instance.

Definition at line 165 of file Validators.h.

165inline std::shared_ptr<Contract> RtspRequiresSource(std::string source_kind = "StillImageInput") {
166 class C final : public Contract {
167 public:
168 explicit C(std::string k) : src_kind_(std::move(k)) {}
169 std::string id() const override {
170 return "RtspRequiresSource";
171 }
172 std::string description() const override {
173 return "RTSP mode requires a server-side source node (e.g., StillImageInput).";
174 }
175
176 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
177 ValidationReport& r) const override {
179 return;
180
181 const auto& v = nodes.nodes();
182 bool found = false;
183 for (int i = 0; i < static_cast<int>(v.size()); ++i) {
184 const auto& n = v[static_cast<std::size_t>(i)];
185 if (n && n->kind() == src_kind_) {
186 found = true;
187 break;
188 }
189 }
190
191 if (!found) {
192 r.add_error(id(), "RTSP_SOURCE_MISSING",
193 "RTSP mode requires a node of kind \"" + src_kind_ + "\".", -1, src_kind_, "");
194 }
195 }
196
197 private:
198 std::string src_kind_;
199 };
200 return std::make_shared<C>(std::move(source_kind));
201}

SinkLastForRun()

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

Ensures the configured sink kind exists and is last when ctx.mode == Run.

This is the builder-level version of the "sink last" contract described in the architecture. Issues SINK_NOT_LAST if the last Node isn't of the expected kind, and MULTIPLE_SINKS if a sink-kind Node is found earlier in the chain.

Parameters
sink_kind

The Node kind expected as the terminal (default "Output").

Returns

Shared pointer to a fresh Contract instance.

Definition at line 108 of file Validators.h.

108inline std::shared_ptr<Contract> SinkLastForRun(std::string sink_kind = "Output") {
109 class C final : public Contract {
110 public:
111 explicit C(std::string kind) : sink_kind_(std::move(kind)) {}
112 std::string id() const override {
113 return "SinkLastForRun";
114 }
115 std::string description() const override {
116 return "When running, the pipeline must end with the terminal appsink node.";
117 }
118
119 void validate(const NodeGroup& nodes, const ValidationContext& ctx,
120 ValidationReport& r) const override {
122 return;
123 const auto& v = nodes.nodes();
124 if (v.empty())
125 return;
126
127 int last_idx = static_cast<int>(v.size()) - 1;
128 const auto& last = v.back();
129 const std::string last_kind = last ? last->kind() : "";
130
131 // Require sink kind last.
132 if (!last || last_kind != sink_kind_) {
133 r.add_error(id(), "SINK_NOT_LAST", "Last node must be " + sink_kind_ + " for run().",
134 last_idx, last_kind, last ? last->user_label() : "");
135 }
136
137 // Disallow additional sinks earlier (best-effort sanity).
138 for (int i = 0; i < last_idx; ++i) {
139 const auto& n = v[static_cast<std::size_t>(i)];
140 if (n && n->kind() == sink_kind_) {
141 r.add_error(id(), "MULTIPLE_SINKS",
142 "Found " + sink_kind_ + " before the end of the pipeline.", i, n->kind(),
143 n->user_label());
144 }
145 }
146 }
147
148 private:
149 std::string sink_kind_;
150 };
151 return std::make_shared<C>(std::move(sink_kind));
152}

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.