21 template <
typename T >
22 [[nodiscard]] std::shared_ptr< const T >
at( std::size_t idx )
const {
23 return std::static_pointer_cast<
const T >(
impAt( idx ) ) ;
31 template <
typename T >
32 std::shared_ptr< T >
at( std::size_t idx ) {
33 return std::static_pointer_cast< T >(
impAt( idx ) ) ;
40 template <
typename T >
41 std::shared_ptr< const T >
merged() {
42 return std::static_pointer_cast<
const T >(
impMerged() ) ;
54 [[nodiscard]]
virtual std::shared_ptr< void >
55 impAt( std::size_t idx )
const = 0 ;
57 [[nodiscard]]
virtual std::shared_ptr< void >
impMerged() = 0 ;
65 template <
typename T,
66 void ( *MERGE )(
const std::shared_ptr< T > & ,
67 const std::shared_ptr< T > &
79 : _objects{num_instances,
nullptr},
81 std::make_unique< typename decltype( _ctor_p )::element_type >(
83 for ( std::shared_ptr< T > &pObj : _objects ) {
84 pObj = std::make_shared< T >( args... ) ;
96 [[nodiscard]] std::shared_ptr< void >
97 impAt( std::size_t idx )
const override final {
98 return _objects[idx] ;
101 [[nodiscard]] std::shared_ptr< void >
impMerged() override final {
103 = std::make_shared< T >( std::make_from_tuple< T >( *_ctor_p ) ) ;
104 for ( std::shared_ptr< T > &pObj : _objects ) {
106 ( *MERGE )( _mergedObj, pObj ) ;
112 std::vector< std::shared_ptr< T > >
114 std::shared_ptr< T > _mergedObj{
nullptr} ;
116 std::tuple< const typename std::remove_reference< Args_t >::type... > >
124 template <
typename T,
typename... Args_t >
128 : _object{std::make_shared< T >( args... )} {}
137 [[nodiscard]] std::shared_ptr< void >
138 impAt( std::size_t )
const override final {
143 [[nodiscard]] std::shared_ptr< void >
impMerged() override final {
147 std::shared_ptr< T > _object{
nullptr} ;
virtual std::shared_ptr< void > impAt(std::size_t idx) const =0
implementation from at
MemLayout base class to store booked objects in MarlinMT.
MemLayout for mutable object instances.
virtual ~MemLayout()=default
std::shared_ptr< const T > merged()
Get Completed Resource.
MemLayout & operator=(const MemLayout &)=default
std::vector< std::shared_ptr< T > > _objects
std::shared_ptr< void > impAt(std::size_t) const override final
implementation from at
std::unique_ptr< std::tuple< const typename std::remove_reference< Args_t >::type... > > _ctor_p
std::shared_ptr< void > impAt(std::size_t idx) const override final
Get Resource for Instance. Lazy operation.
std::shared_ptr< const T > at(std::size_t idx) const
Get Resource for an instance.
std::shared_ptr< void > impMerged() override final
std::shared_ptr< void > impMerged() override final
implementation from merged
SingleMemLayout(Args_t... args)
virtual std::shared_ptr< void > impMerged()=0
implementation from merged
MemLayout for Single object instance.
std::shared_ptr< T > at(std::size_t idx)
Get Resource for an instance.
SharedMemLayout(std::size_t num_instances, Args_t... args)
Constructor.