SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT > Class Template Reference

#include <prepared.hpp>

Collaboration diagram for serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >:
[legend]

Public Types

using Traits = detail::PreparedTraits<PlanT, ContextT, ErrorT>
 
using Bindings = typename Traits::Bindings
 
using Sources = typename Traits::Sources
 
using Report = PreparationReport<typename PlanT::Results, Sources>
 
using Failure = PreparationFailure<ErrorT>
 

Public Member Functions

 Prepared (PlanT plan)
 Own a plan and its accepted cache; contexts are supplied separately to each preparation.
 
 Prepared (const Prepared &)=delete
 
Prepared & operator= (const Prepared &)=delete
 
 Prepared (Prepared &&other)
 Transfer accepted results while leaving the original object unprepared.
 
Prepared & operator= (Prepared &&)=delete
 
template<IsDeclaration RequestedT = typename PlanT::Results>
requires detail::declaration_subset_v<std::remove_cvref_t<RequestedT>, typename PlanT::Results>
std::expected< Report, Failure > try_prepare (const ContextT &context, RequestedT={}, const PreparationMode mode=PreparationMode::reuse_unchanged)
 Prepare the requested results and their prerequisites, publishing only a complete successful candidate.
 
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename PlanT::Results>
bool contains () const
 Test whether a result belongs to the latest successful request, including its prerequisites.
 
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename PlanT::Results>
const auto & get () const
 Read a frozen result. References remain valid until the next preparation or invalidation.
 
const Report & report () const noexcept
 Report reuse and rebuilding from the latest successful preparation.
 
bool ready () const noexcept
 A failed preparation makes all result access unavailable until a subsequent success.
 
void invalidate () noexcept
 Discard accepted snapshots and results, requiring fresh preparation on the next request.
 

Private Types

using Storage = detail::PreparedStorage<PlanT, Bindings, typename Traits::Resources, std::make_index_sequence<PlanT::size>>
 
using ResultMask = typename PlanT::Graph::Mask
 
using SourceMask = std::array<bool, source_count>
 

Private Member Functions

template<typename KeyT>
void inspect_source (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, PreparationMode mode) const
 Inspect each required source once; other context objects need no snapshot policy.
 
template<typename KeyT>
const auto & input (const ContextT &context, const Storage &candidate) const
 Computations read either a supplied source or a prerequisite already prepared in this candidate.
 
template<std::size_t Index, typename... Keys>
std::expected< void, Failure > prepare_one (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, PreparationMode mode, Declaration< Keys... >) const
 Reuse a result only when every input version matches its accepted version.
 
template<std::size_t Position>
std::expected< void, Failure > prepare_in_order (const ContextT &context, Storage &candidate, Report &report, SourceMask &inspected, const ResultMask &required, PreparationMode mode) const
 Follow the compile-time order while skipping branches outside the requested closure.
 

Static Private Member Functions

template<typename KeyT>
static consteval std::size_t version_index ()
 Share one version namespace between source snapshots and computed results.
 

Private Attributes

PlanT m_plan
 
Storage m_storage
 
Report m_report
 
ResultMask m_active {}
 
bool m_ready {false}
 

Static Private Attributes

static constexpr std::size_t source_count = detail::DeclarationSize<Sources>::value
 

Member Typedef Documentation

◆ Bindings

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Bindings = typename Traits::Bindings

◆ Failure

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Failure = PreparationFailure<ErrorT>

◆ Report

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Report = PreparationReport<typename PlanT::Results, Sources>

◆ ResultMask

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::ResultMask = typename PlanT::Graph::Mask
private

◆ SourceMask

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::SourceMask = std::array<bool, source_count>
private

◆ Sources

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Sources = typename Traits::Sources

◆ Storage

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Storage = detail::PreparedStorage<PlanT, Bindings, typename Traits::Resources, std::make_index_sequence<PlanT::size>>
private

◆ Traits

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
using serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Traits = detail::PreparedTraits<PlanT, ContextT, ErrorT>

Constructor & Destructor Documentation

◆ Prepared() [1/3]

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Prepared ( PlanT plan)
inlineexplicit

Own a plan and its accepted cache; contexts are supplied separately to each preparation.

◆ Prepared() [2/3]

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Prepared ( const Prepared< PlanT, ContextT, ErrorT > & )
delete

◆ Prepared() [3/3]

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::Prepared ( Prepared< PlanT, ContextT, ErrorT > && other)
inline

Transfer accepted results while leaving the original object unprepared.

Member Function Documentation

◆ contains()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename PlanT::Results>
bool serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::contains ( ) const
inlinenodiscard

Test whether a result belongs to the latest successful request, including its prerequisites.

◆ get()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<typename KeyT>
requires detail::contains_key_v<KeyT, typename PlanT::Results>
const auto & serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::get ( ) const
inlinenodiscard

Read a frozen result. References remain valid until the next preparation or invalidation.

◆ input()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<typename KeyT>
const auto & serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::input ( const ContextT & context,
const Storage & candidate ) const
inlinenodiscardprivate

Computations read either a supplied source or a prerequisite already prepared in this candidate.

◆ inspect_source()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<typename KeyT>
void serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::inspect_source ( const ContextT & context,
Storage & candidate,
Report & report,
SourceMask & inspected,
PreparationMode mode ) const
inlineprivate

Inspect each required source once; other context objects need no snapshot policy.

◆ invalidate()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
void serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::invalidate ( )
inlinenoexcept

Discard accepted snapshots and results, requiring fresh preparation on the next request.

◆ operator=() [1/2]

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
Prepared & serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::operator= ( const Prepared< PlanT, ContextT, ErrorT > & )
delete

◆ operator=() [2/2]

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
Prepared & serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::operator= ( Prepared< PlanT, ContextT, ErrorT > && )
delete

◆ prepare_in_order()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<std::size_t Position>
std::expected< void, Failure > serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::prepare_in_order ( const ContextT & context,
Storage & candidate,
Report & report,
SourceMask & inspected,
const ResultMask & required,
PreparationMode mode ) const
inlinenodiscardprivate

Follow the compile-time order while skipping branches outside the requested closure.

◆ prepare_one()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<std::size_t Index, typename... Keys>
std::expected< void, Failure > serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::prepare_one ( const ContextT & context,
Storage & candidate,
Report & report,
SourceMask & inspected,
PreparationMode mode,
Declaration< Keys... >  ) const
inlinenodiscardprivate

Reuse a result only when every input version matches its accepted version.

◆ ready()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
bool serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::ready ( ) const
inlinenodiscardnoexcept

A failed preparation makes all result access unavailable until a subsequent success.

◆ report()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
const Report & serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::report ( ) const
inlinenodiscardnoexcept

Report reuse and rebuilding from the latest successful preparation.

◆ try_prepare()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<IsDeclaration RequestedT = typename PlanT::Results>
requires detail::declaration_subset_v<std::remove_cvref_t<RequestedT>, typename PlanT::Results>
std::expected< Report, Failure > serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::try_prepare ( const ContextT & context,
RequestedT = {},
const PreparationMode mode = PreparationMode::reuse_unchanged )
inlinenodiscard

Prepare the requested results and their prerequisites, publishing only a complete successful candidate.

◆ version_index()

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
template<typename KeyT>
static consteval std::size_t serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::version_index ( )
inlinestaticnodiscardconstevalprivate

Share one version namespace between source snapshots and computed results.

Member Data Documentation

◆ m_active

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
ResultMask serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::m_active {}
private

◆ m_plan

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
PlanT serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::m_plan
private

◆ m_ready

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
bool serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::m_ready {false}
private

◆ m_report

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
Report serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::m_report
private

◆ m_storage

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
Storage serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::m_storage
private

◆ source_count

template<typename PlanT, typename ContextT, typename ErrorT = std::string>
std::size_t serif::utils::dependencies::Prepared< PlanT, ContextT, ErrorT >::source_count = detail::DeclarationSize<Sources>::value
staticconstexprprivate

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