18#include <vulcan/time/Epoch.hpp>
45 void set_context(
const std::string &entity,
const std::string &component) {
47 component_ = component;
56 void set_epoch(
const vulcan::time::Epoch<Scalar> *epoch) { epoch_ = epoch; }
65 comp.BindEpoch(epoch_);
74 registry_.clear_current_component();
83 return entity_ +
"." + component_;
99 void register_output(
const std::string &local_name, T *data_ptr,
const std::string &unit =
"",
100 const std::string &description =
"") {
101 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
102 std::string full_name = make_full_name(local_name);
104 registered_outputs_.push_back(full_name);
110 template <
typename S>
112 const std::string &unit =
"",
const std::string &description =
"") {
113 std::string full_name = make_full_name(local_name);
115 registered_outputs_.push_back(full_name +
".x");
116 registered_outputs_.push_back(full_name +
".y");
117 registered_outputs_.push_back(full_name +
".z");
123 template <
typename S>
125 const std::string &unit =
"",
const std::string &description =
"") {
126 std::string full_name = make_full_name(local_name);
128 registered_outputs_.push_back(full_name +
".w");
129 registered_outputs_.push_back(full_name +
".x");
130 registered_outputs_.push_back(full_name +
".y");
131 registered_outputs_.push_back(full_name +
".z");
151 template <
typename T>
153 const std::string &unit =
"",
const std::string &description =
"") {
154 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
155 std::string full_name = make_full_name(local_name);
156 registry_.template
register_state<T>(full_name, value, derivative, unit, description);
157 registered_outputs_.push_back(full_name);
158 registered_outputs_.push_back(full_name +
"_dot");
166 template <
typename S>
168 const std::string &unit =
"",
const std::string &description =
"") {
169 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
170 std::string full_name = make_full_name(local_name);
173 registered_outputs_.push_back(full_name +
".x");
174 registered_outputs_.push_back(full_name +
".y");
175 registered_outputs_.push_back(full_name +
".z");
176 registered_outputs_.push_back(full_name +
"_dot.x");
177 registered_outputs_.push_back(full_name +
"_dot.y");
178 registered_outputs_.push_back(full_name +
"_dot.z");
186 template <
typename S>
188 const std::string &unit =
"",
const std::string &description =
"") {
189 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
190 std::string full_name = make_full_name(local_name);
193 registered_outputs_.push_back(full_name +
".w");
194 registered_outputs_.push_back(full_name +
".x");
195 registered_outputs_.push_back(full_name +
".y");
196 registered_outputs_.push_back(full_name +
".z");
197 registered_outputs_.push_back(full_name +
"_dot.w");
198 registered_outputs_.push_back(full_name +
"_dot.x");
199 registered_outputs_.push_back(full_name +
"_dot.y");
200 registered_outputs_.push_back(full_name +
"_dot.z");
216 resolved_inputs_.push_back(full_name);
217 return registry_.template
resolve<T>(full_name);
224 resolved_inputs_.push_back(full_name +
".x");
225 resolved_inputs_.push_back(full_name +
".y");
226 resolved_inputs_.push_back(full_name +
".z");
234 resolved_inputs_.push_back(full_name +
".w");
235 resolved_inputs_.push_back(full_name +
".x");
236 resolved_inputs_.push_back(full_name +
".y");
237 resolved_inputs_.push_back(full_name +
".z");
244 [[nodiscard]]
bool has_signal(
const std::string &full_name)
const {
245 return registry_.HasSignal(full_name);
261 template <
typename T>
263 const std::string &units =
"",
const std::string &description =
"") {
264 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
265 std::string full_name = make_full_name(local_name);
266 handle->set_name(local_name);
267 handle->set_full_name(full_name);
269 registered_inputs_.push_back(full_name);
279 void register_param(
const std::string &local_name, Scalar *storage, Scalar initial_value,
280 const std::string &units =
"",
const std::string &description =
"") {
281 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
282 std::string full_name = make_full_name(local_name);
283 registry_.register_param(full_name, storage, initial_value, units, description);
284 registered_params_.push_back(full_name);
295 const std::string &description =
"") {
296 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
297 std::string full_name = make_full_name(local_name);
298 registry_.register_config(full_name, storage, initial_value, description);
299 registered_config_.push_back(full_name);
305 void register_config(
const std::string &local_name,
bool *storage,
bool initial_value,
306 const std::string &description =
"") {
307 ICARUS_ASSERT(!component_.empty(),
"Context must be set before registration");
308 std::string full_name = make_full_name(local_name);
309 registry_.register_config(full_name, storage, initial_value, description);
310 registered_config_.push_back(full_name);
320 template <
typename T>
321 void wire_input(
const std::string &input_name,
const std::string &source_name) {
342 template <
typename T>
343 void declare_output(
const std::string &local_name, T *data_ptr,
const std::string &unit =
"",
344 const std::string &description =
"") {
351 template <
typename S>
353 const std::string &unit =
"",
const std::string &description =
"") {
368 template <
typename T>
370 const std::string &unit =
"",
const std::string &description =
"") {
388 template <
typename T>
389 void WireWithGain(
const std::string &input_path,
const std::string &output_path,
391 registry_.template wire_input_with_gain<T>(input_path, output_path, gain);
399 void WireWithGain(
const std::string &input_path,
const std::string &output_path,
401 registry_.wire_input_with_gain(input_path, output_path, gain);
411 [[nodiscard]]
bool HasOutput(
const std::string &full_name)
const {
412 return registry_.HasOutput(full_name);
418 [[nodiscard]]
bool HasInput(
const std::string &full_name)
const {
419 return registry_.HasInput(full_name);
428 return registry_.GetAllInputPaths();
435 return registry_.GetAllOutputPaths();
446 return registered_outputs_;
453 return registered_inputs_;
460 return resolved_inputs_;
467 return registered_params_;
474 return registered_config_;
481 registered_outputs_.clear();
482 registered_inputs_.clear();
483 resolved_inputs_.clear();
484 registered_params_.clear();
485 registered_config_.clear();
496 [[nodiscard]] std::string make_full_name(
const std::string &local_name)
const {
500 return prefix +
"." + local_name;
503 SignalRegistry<Scalar> ®istry_;
505 std::string component_;
506 std::vector<std::string> registered_outputs_;
507 std::vector<std::string> registered_inputs_;
508 std::vector<std::string> resolved_inputs_;
509 std::vector<std::string> registered_params_;
510 std::vector<std::string> registered_config_;
511 const vulcan::time::Epoch<Scalar> *epoch_ =
nullptr;
Core type definitions, concepts, and configuration for Icarus.
#define ICARUS_ASSERT(cond, msg)
Definition CoreTypes.hpp:258
Type-safe SignalHandle for zero-overhead hot path access.
Signal Registry (Backplane) for Icarus.
Vector and matrix handles for structured signal access.
void register_input(const std::string &local_name, InputHandle< T > *handle, const std::string &units="", const std::string &description="")
Register an input port.
Definition Backplane.hpp:262
void register_output(const std::string &local_name, T *data_ptr, const std::string &unit="", const std::string &description="")
Register a scalar output signal.
Definition Backplane.hpp:99
void register_output_vec3(const std::string &local_name, Vec3< S > *data_ptr, const std::string &unit="", const std::string &description="")
Register a Vec3 output signal (expands to .x/.y/.z).
Definition Backplane.hpp:111
bool has_signal(const std::string &full_name) const
Check if a signal exists.
Definition Backplane.hpp:244
void register_state_vec3(const std::string &local_name, Vec3< S > *value, Vec3< S > *derivative, const std::string &unit="", const std::string &description="")
Register a Vec3 state with its derivative.
Definition Backplane.hpp:167
void declare_output_vec3(const std::string &local_name, Vec3< S > *data_ptr, const std::string &unit="", const std::string &description="")
Declare a Vec3 output port.
Definition Backplane.hpp:352
std::vector< std::string > GetDeclaredInputs() const
Get all declared input paths.
Definition Backplane.hpp:427
SignalRegistry< Scalar > & registry()
Definition Backplane.hpp:492
void declare_output(const std::string &local_name, T *data_ptr, const std::string &unit="", const std::string &description="")
Declare an output port (Phase 4.0 semantic alias for register_output).
Definition Backplane.hpp:343
const std::vector< std::string > & resolved_inputs() const
Get legacy resolved inputs by current component.
Definition Backplane.hpp:459
void register_config(const std::string &local_name, bool *storage, bool initial_value, const std::string &description="")
Register a bool config value.
Definition Backplane.hpp:305
Vec3Handle< S > resolve_vec3(const std::string &full_name)
Resolve a Vec3 signal.
Definition Backplane.hpp:223
void WireWithGain(const std::string &input_path, const std::string &output_path, double gain=1.0)
Wire an input to a source with a gain factor.
Definition Backplane.hpp:389
void set_epoch(const vulcan::time::Epoch< Scalar > *epoch)
Set epoch reference for component binding.
Definition Backplane.hpp:56
void register_output_quat(const std::string &local_name, Vec4< S > *data_ptr, const std::string &unit="", const std::string &description="")
Register a quaternion output signal (expands to .w/.x/.y/.z).
Definition Backplane.hpp:124
const std::vector< std::string > & registered_params() const
Get parameters registered by current component (Phase 2.4).
Definition Backplane.hpp:466
void set_context(const std::string &entity, const std::string &component)
Set current component context.
Definition Backplane.hpp:45
SignalHandle< T > resolve(const std::string &full_name)
Resolve a signal by full path.
Definition Backplane.hpp:215
bool HasOutput(const std::string &full_name) const
Check if an output signal exists.
Definition Backplane.hpp:411
void register_state(const std::string &local_name, T *value, T *derivative, const std::string &unit="", const std::string &description="")
Register a scalar state with its derivative.
Definition Backplane.hpp:152
Backplane(SignalRegistry< Scalar > ®istry)
Definition Backplane.hpp:34
void wire_input(const std::string &input_name, const std::string &source_name)
Wire an input to a source signal.
Definition Backplane.hpp:321
void bind_epoch_to(ComponentType &comp)
Bind epoch reference to a component.
Definition Backplane.hpp:64
void clear_tracking()
Clear tracking for next component.
Definition Backplane.hpp:480
void clear_context()
Clear the current context.
Definition Backplane.hpp:71
std::vector< std::string > GetDeclaredOutputs() const
Get all declared output paths.
Definition Backplane.hpp:434
const std::vector< std::string > & registered_inputs() const
Get inputs registered by current component (Phase 2.4).
Definition Backplane.hpp:452
QuatHandle< S > resolve_quat(const std::string &full_name)
Resolve a quaternion signal.
Definition Backplane.hpp:233
void register_config(const std::string &local_name, int *storage, int initial_value, const std::string &description="")
Register an int config value.
Definition Backplane.hpp:294
const std::vector< std::string > & registered_config() const
Get config registered by current component (Phase 2.4).
Definition Backplane.hpp:473
std::string full_prefix() const
Get full prefix: entity.component (or just component if no entity).
Definition Backplane.hpp:80
void declare_input(const std::string &local_name, InputHandle< T > *handle, const std::string &unit="", const std::string &description="")
Declare an input port (Phase 4.0 semantic alias for register_input).
Definition Backplane.hpp:369
const std::vector< std::string > & registered_outputs() const
Get outputs registered by current component.
Definition Backplane.hpp:445
void register_state_quat(const std::string &local_name, Vec4< S > *value, Vec4< S > *derivative, const std::string &unit="", const std::string &description="")
Register a quaternion state with its derivative.
Definition Backplane.hpp:187
void register_param(const std::string &local_name, Scalar *storage, Scalar initial_value, const std::string &units="", const std::string &description="")
Register a Scalar parameter (optimizable).
Definition Backplane.hpp:279
bool HasInput(const std::string &full_name) const
Check if an input port exists.
Definition Backplane.hpp:418
void WireWithGain(const std::string &input_path, const std::string &output_path, double gain=1.0)
Wire with gain (type-erased version for SignalRouter).
Definition Backplane.hpp:399
const SignalRegistry< Scalar > & registry() const
Definition Backplane.hpp:493
Type-safe handle for accessing a signal value.
Definition Handle.hpp:41
Central registry for all simulation signals.
Definition Registry.hpp:37
Concept for types that can serve as Icarus components.
Definition CoreTypes.hpp:189
Definition AggregationTypes.hpp:13
Handle for accessing a quaternion signal as four scalar components.
Definition VecHandle.hpp:74
Handle for accessing a Vec3 signal as three scalar components.
Definition VecHandle.hpp:39