gtopt::InputContext class

Base classes

template<typename SystemLP_Type>
class ElementContext<SystemLP>
Provides a context for interacting with elements within a SystemLP.
struct InputTraits
Input data access traits.

Public types

template<typename... Uid>
using array_table_vector_uid_idx_t = std::tuple<array_uid_idx_map_t<Uid...>, table_uid_idx_map_t<Uid...>, vector_uid_idx_t<Uid...>>
template<typename... Uid>
using array_uid_idx_map_t = base_map_t<CFNameUid, arrow_array_uid_idx_t<Uid...>>
template<typename... Uid>
using array_vector_uid_idx_v = std::variant<arrow_array_uid_idx_t<Uid...>, vector_uid_idx_t<Uid...>>
template<typename... Uid>
using arrow_array_uid_idx_t = std::tuple<ArrowChunkedArray, ArrowUidIdx<Uid...>, PresentMask>
template<typename... Uid>
using arrow_table_uid_idx_t = std::tuple<ArrowTable, ArrowUidIdx<Uid...>, PresentMask>
template<typename... Uid>
using ArrowUidIdx = UidToArrowIdx<Uid...>::UidIdx
template<typename Key, typename Value>
using base_map_t = gtopt::flat_map<Key, Value>
using CFName = std::tuple<ClassNameType, FieldNameType>
using CFNameUid = std::tuple<ClassNameType, FieldNameType, Uid>
using ClassNameType = std::string_view
using FieldNameType = std::string_view
template<typename... Uid>
using idx_key_t = UidToVectorIdx<Uid...>::IndexKey
template<typename value_type, typename... Uid>
using idx_vector_t = mvector_traits<value_type, idx_key_t<Uid...>>::vector_type
using PresentMask = ArrowPresentMask
template<typename... Uid>
using table_uid_idx_map_t = base_map_t<CFName, arrow_table_uid_idx_t<Uid...>>
template<typename... Uid>
using vector_uid_idx_t = VectorUidIdx<Uid...>
template<typename... Uid>
using VectorUidIdx = UidToVectorIdx<Uid...>::UidIdx

Public static functions

template<typename Type, typename RType = Type, typename FSched, typename UidIdx UidIdx, typename AccessOper, typename... Uid>
static auto access_sched(const FSched& sched, const UidIdx& uid_idx, AccessOper access_oper, Uid... uid) -> RType
template<typename Type, typename FSched, typename UidIdx UidIdx, typename... Uid>
static auto at_sched(const FSched& sched, const UidIdx& uid_idx, Uid... uid) -> Type
template<typename Type, typename FSched, typename UidIdx UidIdx, typename... Uid>
static auto optval_sched(const FSched& sched, const UidIdx& uid_idx, Uid... uid) -> std::optional<Type>
template<typename Tuple>
static auto project_key(const Tuple& key, PresentMask mask) -> Tuple noexcept
template<typename Tuple, std::size_t... I>
static auto project_key_impl(const Tuple& key, PresentMask mask, std::index_sequence<I...>) -> Tuple noexcept

Constructors, destructors, conversion operators

InputContext(const SystemContext& system_context) explicit

Public functions

auto add_element(Element&& element) -> auto
Adds a new element to the system.
auto element(const Id<Element>& id) const -> auto&&
Gets a reference to an element by its ID.
auto element_index(const Id<Element>& id) const -> auto
Gets the index of an element by its ID.
template<typename Element>
auto element_index(const ObjectSingleId<Element>& id) const -> ElementIndex<Element>
auto elements() const -> auto&&
Gets a container of all elements of a specific type.
template<typename Type, typename FSched, typename... Uids>
auto get_array_index(const FSched& sched, std::string_view cname, const Id& id) const -> auto
auto make_element_index(this Self&& self, const Object& objori, const std::variant<Uid, Name, Attrs>& element_var) -> ElementIndex<Element>
Finds an existing element's index or creates a new one.
auto system_context() const -> auto&&
auto system_lp(this auto& self) -> SystemLP& noexcept
Gets the underlying SystemLP object.

Typedef documentation

template<typename... Uid>
using gtopt::InputContext::array_table_vector_uid_idx_t = std::tuple<array_uid_idx_map_t<Uid...>, table_uid_idx_map_t<Uid...>, vector_uid_idx_t<Uid...>>

template<typename... Uid>
using gtopt::InputContext::array_uid_idx_map_t = base_map_t<CFNameUid, arrow_array_uid_idx_t<Uid...>>

template<typename... Uid>
using gtopt::InputContext::array_vector_uid_idx_v = std::variant<arrow_array_uid_idx_t<Uid...>, vector_uid_idx_t<Uid...>>

template<typename... Uid>
using gtopt::InputContext::arrow_array_uid_idx_t = std::tuple<ArrowChunkedArray, ArrowUidIdx<Uid...>, PresentMask>

template<typename... Uid>
using gtopt::InputContext::arrow_table_uid_idx_t = std::tuple<ArrowTable, ArrowUidIdx<Uid...>, PresentMask>

template<typename... Uid>
using gtopt::InputContext::ArrowUidIdx = UidToArrowIdx<Uid...>::UidIdx

template<typename Key, typename Value>
using gtopt::InputContext::base_map_t = gtopt::flat_map<Key, Value>

using gtopt::InputContext::CFName = std::tuple<ClassNameType, FieldNameType>

using gtopt::InputContext::CFNameUid = std::tuple<ClassNameType, FieldNameType, Uid>

using gtopt::InputContext::ClassNameType = std::string_view

using gtopt::InputContext::FieldNameType = std::string_view

template<typename... Uid>
using gtopt::InputContext::idx_key_t = UidToVectorIdx<Uid...>::IndexKey

template<typename value_type, typename... Uid>
using gtopt::InputContext::idx_vector_t = mvector_traits<value_type, idx_key_t<Uid...>>::vector_type

using gtopt::InputContext::PresentMask = ArrowPresentMask

Bitmask describing which UID dimensions are present in an input table. Bit i corresponds to the i-th UID in the parameter pack. When a bit is 0, the underlying column was absent from the table and the loader has built / will look up the index with a default-constructed UID in that slot — i.e. the value is broadcast across that dimension. See UidToArrowIdx<...>::make_arrow_uids_idx.

template<typename... Uid>
using gtopt::InputContext::table_uid_idx_map_t = base_map_t<CFName, arrow_table_uid_idx_t<Uid...>>

template<typename... Uid>
using gtopt::InputContext::vector_uid_idx_t = VectorUidIdx<Uid...>

template<typename... Uid>
using gtopt::InputContext::VectorUidIdx = UidToVectorIdx<Uid...>::UidIdx

Function documentation

template<typename Type, typename RType = Type, typename FSched, typename UidIdx UidIdx, typename AccessOper, typename... Uid>
static RType gtopt::InputContext::access_sched(const FSched& sched, const UidIdx& uid_idx, AccessOper access_oper, Uid... uid)

template<typename Type, typename FSched, typename UidIdx UidIdx, typename... Uid>
static Type gtopt::InputContext::at_sched(const FSched& sched, const UidIdx& uid_idx, Uid... uid)

template<typename Type, typename FSched, typename UidIdx UidIdx, typename... Uid>
static std::optional<Type> gtopt::InputContext::optval_sched(const FSched& sched, const UidIdx& uid_idx, Uid... uid)

template<typename Tuple>
static Tuple gtopt::InputContext::project_key(const Tuple& key, PresentMask mask) noexcept

template<typename Tuple, std::size_t... I>
static Tuple gtopt::InputContext::project_key_impl(const Tuple& key, PresentMask mask, std::index_sequence<I...>) noexcept

Project a UID tuple onto the dimensions present in mask. Slots whose corresponding bit is zero are replaced by a default-constructed UID — this is the same sentinel that the loader stored in the row index when the column was absent, so the projected key always finds the row that the file intends to broadcast.

auto gtopt::InputContext::add_element(Element&& element)

Adds a new element to the system.

Parameters
element The element to add (rvalue reference).
Returns The ElementIndex of the newly added element.

auto&& gtopt::InputContext::element(const Id<Element>& id) const

Gets a reference to an element by its ID.

Parameters
id The ID of the element.
Returns A reference to the element.
Exceptions
std::out_of_range if the element is not found.

auto gtopt::InputContext::element_index(const Id<Element>& id) const

Gets the index of an element by its ID.

Parameters
id The ID of the element.
Returns The ElementIndex for the given ID.
Exceptions
std::out_of_range if the element is not found.

auto&& gtopt::InputContext::elements() const

Gets a container of all elements of a specific type.

Returns A const reference to the container of elements.
Exceptions
std::runtime_error — propagates from SystemLP::elements<X>() if the per-cell collections are empty (post-release_backend() under non-off low_memory without a preceding rebuild_collections_if_needed()). No longer declared noexcept so the runtime error reaches outer frames.

ElementIndex<Element> gtopt::InputContext::make_element_index(this Self&& self, const Object& objori, const std::variant<Uid, Name, Attrs>& element_var)

Finds an existing element's index or creates a new one.

Parameters
self The ElementContext instance.
objori The original object with base data.
element_var A variant holding either a Uid, a Name, or Attrs.
Returns ElementIndex of the found or created element.

This function attempts to find an element by Uid or Name. If not found, it creates a new element using the provided attributes and original object data.

SystemLP& gtopt::InputContext::system_lp(this auto& self) noexcept

Gets the underlying SystemLP object.

Returns A reference to the SystemLP object, preserving const and value category.