opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
state_view_with_metadata.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <optional>
6
7namespace SimTK { class State; }
8
9namespace opyn
10{
11 // An abstract base class that represents the pairing of a readonly `SimTK::State` with metadata.
13 protected:
17 ~StateViewWithMetadata() noexcept = default;
18
19 StateViewWithMetadata& operator=(const StateViewWithMetadata&) = default;
20 StateViewWithMetadata& operator=(StateViewWithMetadata&&) noexcept = default;
21 friend bool operator==(const StateViewWithMetadata&, const StateViewWithMetadata&) = default;
22
23 public:
24 // Returns a reference to the readonly `SimTK::State` this view is viewing.
25 const SimTK::State& getState() const { return implGetState(); }
26
27 // Returns a single auxiliary value (metadata) associated with the state that this
28 // view is viewing.
29 std::optional<float> getAuxiliaryValue(osc::UID id) const { return implGetAuxiliaryValue(id); }
30
31 private:
32 // Implementors must provide a const accessor to a state
33 virtual const SimTK::State& implGetState() const = 0;
34
35 // Implementors may provide a way of accessing auxiliary (metadata)
36 // associated with the state.
37 virtual std::optional<float> implGetAuxiliaryValue(osc::UID) const { return std::nullopt; }
38 };
39}
Definition state_view_with_metadata.h:12
StateViewWithMetadata(StateViewWithMetadata &&) noexcept=default
StateViewWithMetadata(const StateViewWithMetadata &)=default
virtual std::optional< float > implGetAuxiliaryValue(osc::UID) const
Definition state_view_with_metadata.h:37
std::optional< float > getAuxiliaryValue(osc::UID id) const
Definition state_view_with_metadata.h:29
const SimTK::State & getState() const
Definition state_view_with_metadata.h:25
virtual const SimTK::State & implGetState() const =0
Definition uid.h:14
Definition custom_decoration_generator.h:6
Definition component_registry.h:14