HEBench
hebench::cpp::EngineObject Class Referencefinal

Helper class to encapsulate objects that will cross the boundary of the API Bridge. More...

#include <engine_object.hpp>

Inheritance diagram for hebench::cpp::EngineObject:
Collaboration diagram for hebench::cpp::EngineObject:

Public Member Functions

 EngineObject (const BaseEngine &engine, std::shared_ptr< void > p_obj)
 
 EngineObject (const EngineObject &src)
 
 ~EngineObject () override
 
EngineObjectoperator= (const EngineObject &src)
 
const BaseEngineengine () const
 
template<class T >
T & get ()
 
template<class T >
const T & get () const
 
std::int64_t classTag () const override
 Retrieves the tag of the class to which this object belongs. More...
 
- Public Member Functions inherited from hebench::cpp::ITaggedObject
 ITaggedObject ()
 
virtual ~ITaggedObject ()
 

Static Public Attributes

static constexpr std::int64_t tag = 0x2000000000000000
 Used to identify this class when returned as a handle to Test Harness. More...
 
- Static Public Attributes inherited from hebench::cpp::ITaggedObject
static constexpr std::int64_t MaskByteSet = 0xFF
 
static constexpr std::int64_t MaskReservedBits = MaskByteSet << 56
 Mask representing all bits reserved by C++ wrapper. More...
 

Detailed Description

Helper class to encapsulate objects that will cross the boundary of the API Bridge.

This class is provided to ease the creation of handles to backend internal objects (other than engine and benchmarks).

It is recommended to use BaseEngine::createHandle<ObjType>() to create HEBench opaque handles that wrap objects in an instance of this class that can cross the boundary of the API bridge. Use method BaseEngine::retrieveFromHandle<ObjType>() to retrieve the wrapped object, and BaseEngine::duplicateHandle() to create reference-counted handle duplicates.

When using this object directly, instead of the recommended wrappers, users should keep in mind that the method T &EngineObject::get<T>() allows the retrieval of a reference to the created object of type T by the backend when needed. However, the casting of the internal object by this method is unsafe. Users must ensure that the object contained is of the right type (such as using the tag field in the handle for extra information).

Implementation of the API Bridge by this C++ wrapper will properly free and destroy pointers to EngineObject instances, and calling the appropriate destructor of the wrapped object of type T when reference counts reach 0, if assigned to handles as follows:

EngineObject *p_engine_object = ...
hebench::APIBridge::Handle handle;
handle.p = p_engine_object;
handle.size = ... // backend implementation dependent
handle.tag = p_engine_object->classTag() | other_bit_mask_tag_values;
EngineObject(const BaseEngine &engine, std::shared_ptr< void > p_obj)

For the automation to work well, the handle tag must satify:

static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.

Definition at line 102 of file engine_object.hpp.

Constructor & Destructor Documentation

◆ EngineObject() [1/2]

hebench::cpp::EngineObject::EngineObject ( const BaseEngine engine,
std::shared_ptr< void >  p_obj 
)
inline

Definition at line 114 of file engine_object.hpp.

◆ EngineObject() [2/2]

hebench::cpp::EngineObject::EngineObject ( const EngineObject src)
inline

Definition at line 120 of file engine_object.hpp.

◆ ~EngineObject()

hebench::cpp::EngineObject::~EngineObject ( )
inlineoverride

Definition at line 124 of file engine_object.hpp.

Member Function Documentation

◆ classTag()

std::int64_t hebench::cpp::EngineObject::classTag ( ) const
inlineoverridevirtual

Retrieves the tag of the class to which this object belongs.

Most significant 8 bits of the 64-bit tag are reserved by C++ wrapper. See ITaggedObject for more details.

Implements hebench::cpp::ITaggedObject.

Definition at line 151 of file engine_object.hpp.

◆ engine()

const BaseEngine& hebench::cpp::EngineObject::engine ( ) const
inline

Definition at line 138 of file engine_object.hpp.

◆ get() [1/2]

template<class T >
T& hebench::cpp::EngineObject::get ( )
inline

Definition at line 141 of file engine_object.hpp.

◆ get() [2/2]

template<class T >
const T& hebench::cpp::EngineObject::get ( ) const
inline

Definition at line 146 of file engine_object.hpp.

◆ operator=()

EngineObject& hebench::cpp::EngineObject::operator= ( const EngineObject src)
inline

Definition at line 125 of file engine_object.hpp.

Member Data Documentation

◆ tag

constexpr std::int64_t hebench::cpp::EngineObject::tag = 0x2000000000000000
staticconstexpr

Used to identify this class when returned as a handle to Test Harness.

See also
ITaggedObject

Definition at line 112 of file engine_object.hpp.


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