Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
PlantingHandle< BA, DEFAULT > Class Template Reference

#include "lib/opaque-holder.hpp"

Description

template<class BA, class DEFAULT = BA>
class lib::PlantingHandle< BA, DEFAULT >

A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBuffer, without having to disclose the concrete buffer type or size.

Remarks
this copyable value object is especially geared towards use as handle in APIs, allowing a not yet known implementation to implant an agent or collaboration partner into the likewise undisclosed innards of the service exposed.
Warning
the type BA must expose a virtual dtor, since the targeted InPlaceBuffer has to take ownership of the implanted object.
Note
the siz (buffer size) template parameter from #InPlaceBuffer is deliberately not part of the PlantingHandle<BA,DEFAULT> type, since buffer size can be considered an opaque implementation detail. As a consequence, we must capture this size information at construction time and store it at runtime maxSiz_, to protect against buffer overrun.
See also
OpaqueUncheckedBuffer_test

Definition at line 771 of file opaque-holder.hpp.

Public Member Functions

template<size_t maxSiz>
 PlantingHandle (InPlaceBuffer< BA, maxSiz, DEFAULT > &targetBuffer)
 
template<class SUB >
bool canCreate () const
 
template<class SUB >
SUB & emplace (SUB &&implementation)
 move-construct an instance of a subclass into the opaque buffer
 
template<class SUB , typename... ARGS>
SUB & create (ARGS &&...args)
 Abbreviation for placement new of a subclass SUB into the opaque buffer.
 
BA * get () const
 

Private Member Functions

template<class SUB >
void __ensure_can_create ()
 

Private Attributes

void * buffer_
 
size_t maxSiz_
 

Constructor & Destructor Documentation

◆ PlantingHandle()

template<class BA , class DEFAULT = BA>
template<size_t maxSiz>
PlantingHandle ( InPlaceBuffer< BA, maxSiz, DEFAULT > &  targetBuffer)
inline

Definition at line 786 of file opaque-holder.hpp.

Member Function Documentation

◆ __ensure_can_create()

template<class BA , class B0 >
template<class SUB >
void __ensure_can_create ( )
inlineprivate

Helper to ensure the opaque buffer provides sufficient storage

Template Parameters
SUBactual subclass type to be implanted into the opaque buffer

Definition at line 847 of file opaque-holder.hpp.

◆ canCreate()

template<class BA , class DEFAULT = BA>
template<class SUB >
bool canCreate ( ) const
inline

Definition at line 796 of file opaque-holder.hpp.

References PlantingHandle< BA, DEFAULT >::maxSiz_.

◆ emplace()

template<class BA , class DEFAULT = BA>
template<class SUB >
SUB & emplace ( SUB &&  implementation)
inline

◆ create()

template<class BA , class DEFAULT = BA>
template<class SUB , typename... ARGS>
SUB & create ( ARGS &&...  args)
inline

Abbreviation for placement new of a subclass SUB into the opaque buffer.

Definition at line 819 of file opaque-holder.hpp.

References PlantingHandle< BA, DEFAULT >::buffer_.

Referenced by ClipPresenter::buildGestureObserver().

+ Here is the caller graph for this function:

◆ get()

template<class BA , class DEFAULT = BA>
BA * get ( ) const
inline

Definition at line 831 of file opaque-holder.hpp.

References PlantingHandle< BA, DEFAULT >::buffer_.

Referenced by DiffApplicationStrategy< TAR, enable_if< TreeDiffTraits< TAR > > >::buildMutator(), WrappedStandardExeBuilder::invokeOriginalBuilder(), and TreeDiffMutatorBinding::mut().

+ Here is the caller graph for this function:

Member Data Documentation

◆ buffer_

template<class BA , class DEFAULT = BA>
void* buffer_
private

◆ maxSiz_

template<class BA , class DEFAULT = BA>
size_t maxSiz_
private

Definition at line 774 of file opaque-holder.hpp.

Referenced by PlantingHandle< BA, DEFAULT >::canCreate().

+ Collaboration diagram for PlantingHandle< BA, DEFAULT >:

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