MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ expose_typed()

template<typename Source, typename Access = Reflect::RecordAccess<Source>>
template<typename T, Reflect::Described Input, Reflect::Described Placement, typename Factory, typename Initial>
void MayaFlux::Portal::Forma::FactoryTable< Source, Access >::expose_typed ( std::string name,
Reflect::RecordBinding< Input, Source, Access > input,
Reflect::RecordBinding< Placement, Source, Access > placement,
Factory factory,
Initial initial,
std::type_identity_t< std::function< void(const Input &, const Placement &, Tend< T > &)> ,
placed = {} )
inline

Expose a factory whose inputs and placement are described types.

The inputs are read from the factory element and the placement from the instance, both strictly through their described members. The document's own attribute names are skipped on the placement. Initial state and the post-placement hook receive the decoded values, so one factory serves a single instance and a bulk placement alike.

Parameters
inputBinding for the factory element.
placementBinding for the instance.
factoryCallable (const Input&, const Placement&, error) returning std::optional of Geometry::Form of T.
initialCallable (const Input&, const Placement&, error) returning std::optional of T, or a pointer to a member of Input or Placement whose value is the initial state.
placedOptional hook called with the decoded values and the placed Tend.

Definition at line 114 of file FactoryTable.hpp.

118 {})
119 {
121 placement.ignore_prefix(std::string(reserved_prefix));
123
125 const Input&, const Placement&, std::string&)>;
126
132 if (!geometry) {
133 if (error.empty())
134 error = "could not create the geometry";
135 return std::nullopt;
136 }
140 value = static_cast<T>(std::invoke(initial, decoded_input));
141 else
142 value = static_cast<T>(std::invoke(initial, decoded_placement));
143 } else {
145 }
146 if (!value) {
147 if (error.empty())
148 error = "could not create the initial state";
149 return std::nullopt;
150 }
152 if (placed) {
155 };
156 }
158 };
159
161 const Source& factory_element, const Source& instance,
163 uint64_t where {};
164 const auto decoded_input = input.read(factory_element, error, &where);
165 if (!decoded_input) {
167 return std::nullopt;
168 }
169 const auto decoded_placement = placement.read(instance, error, &where);
170 if (!decoded_placement) {
172 return std::nullopt;
173 }
175 if (!placer)
177 return placer;
178 };
179
183 uint64_t where {};
184 const auto decoded_input = input.read(factory_element, error, &where);
185 if (!decoded_input) {
187 return std::nullopt;
188 }
190 if (!placements) {
192 return std::nullopt;
193 }
194
196 placers.reserve(placements->size());
197 for (const Placement& decoded_placement : *placements) {
199 if (!placer) {
201 return std::nullopt;
202 }
203 placers.push_back(std::move(*placer));
204 }
205 return placers;
206 };
207
208 m_factories.insert_or_assign(name, std::move(single));
209 m_bulk.insert_or_assign(name, std::move(bulk));
210 }
static std::string located(uint64_t row, std::string_view message)
static Placer make_placer(Geometry::Form< T > form, T initial, std::function< void(Tend< T > &)> after)
Named factories that turn a template's factory element and an instance into placed Forma elements,...
std::optional< std::vector< T > > records_of(const Kakshya::CompositeArray &rows, std::string &error)
Decode every row of a typed Composite array into values.