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

◆ prepare()

template<typename Source, typename Access>
std::optional< Prepared > MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::prepare ( SurfaceMap & surfaces)
inline

Definition at line 110 of file Instantiate.hpp.

111 {
113 for (const SurfaceInstances& entry : m_surfaces) {
114 const auto bound = surfaces.find(entry.id);
115 if (bound == surfaces.end()) {
116 fail(entry.element, "surface " + entry.id + " is not bound by the host");
117 return std::nullopt;
118 }
119 for (size_t i = 0; i < entry.instances.size(); ++i) {
120 const Source& instance = entry.instances[i];
121 const InstanceInfo& info = entry.info[i];
123 if (info.form) {
124 if (const auto call = Access::attribute(*info.form, reserved_call_attribute)) {
125 const typename Calls::Maker* make = m_calls->find(*call);
126 placer = std::invoke(*make, *info.form, instance, info.hit, m_error);
127 } else {
128 placer = vertex_placer(*info.form, instance, info.hit);
129 }
130 } else {
131 const Source& factory_element = m_templates.at(info.template_id);
134 }
135 if (!placer) {
136 if (m_error.empty())
137 fail(instance, "could not prepare the instance");
138 return std::nullopt;
139 }
141 for (const ActionSpec& spec : info.actions) {
142 const typename Actions::Maker* make = m_actions->find(spec.action);
143 auto action = std::invoke(*make, spec.element, m_error);
144 if (!action) {
145 if (m_error.empty())
146 fail(spec.element, "could not prepare the action " + spec.action);
147 return std::nullopt;
148 }
149 actions.push_back(ActionBinding {
150 .filter = spec.filter, .action = std::move(*action) });
151 }
152 prepared.push_back(PreparedInstance {
153 .surface_id = entry.id,
154 .surface = &bound->second,
155 .id = info.id,
157 .placer = std::move(*placer),
158 .layer = info.layer,
159 .actions = std::move(actions),
160 });
161 }
162 }
163 return prepared;
164 }
std::function< std::optional< Action >(const Source &, std::string &)> Maker
std::function< std::optional< Placer >(const Source &, const Source &, const ElementHit &, std::string &)> Maker
std::vector< PreparedInstance > Prepared
std::optional< Placer > vertex_placer(const Source &form, const Source &element, const ElementHit &hit)
The placement of vertices written in a form element, which have no state.
std::vector< SurfaceInstances > m_surfaces
bool fail(const Source &at, std::string message)
std::unordered_map< std::string, Source > m_templates
std::function< std::optional< Placer >(const Source &, const Source &, std::string &)> Instantiator

References MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::ActionSpec::action, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::actions, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::ActionSpec::element, fail(), MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::ActionSpec::filter, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::form, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::hit, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::id, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::layer, m_actions, m_calls, m_error, m_surfaces, m_table, m_templates, MayaFlux::Portal::Forma::reserved_call_attribute, MayaFlux::Portal::Forma::Detail::DocumentWalk< Source, Access >::InstanceInfo::template_id, and vertex_placer().

Referenced by MayaFlux::Portal::Forma::Detail::instantiate().

Here is the call graph for this function:
Here is the caller graph for this function: