Class InferenceEngine::LockedMemory

template<class T>
class LockedMemory : public InferenceEngine::details::LockedMemoryBase<T>

This class represents locked memory for read/write memory.

Public Functions

inline LockedMemory(IAllocator *ptr, void *handle, size_t offsetInBytes = 0)

A constructor.

Parameters
  • ptr – Pointer to IAllocator object

  • handle – Handle provided by allocator

  • offsetInBytes – Offset in originally locked region

LockedMemory(LockedMemory<T>&&) = default

A default copy constructor, accepting rvalue.

inline LockedMemory(LockedMemory<T> &&that, size_t offset)

A default copy constructor that accepts rvalue.

Also sets the offset value for the new memory object

Parameters
  • that – Rvalue reference for the other LockedMemoryBase instance

  • offset – Offset value

LockedMemory(const LockedMemory<T>&) = delete

A disabled copy constructor for lvalue.

inline operator T*()

Gets a pointer to the stored object.

Dereferences from the base class.

Returns

The pointer to the object of the given template type

inline operator const T*() const

Gets the const pointer to the stored object.

Dereferences from the base class.

Returns

The const pointer object of the given template type.

inline bool operator==(const T *pointer) const

Compares stored object with the given one.

Parameters

pointer – An pointer to compare with.

Returns

true if objects are equal, false otherwise

template<class S, typename = std::enable_if<std::is_pointer<S>::value>>
inline S as()

Casts stored object to any provided type.

Uses reinterpret_cast.

Template Parameters

S – Type to be casted to

Returns

Casted to the given type object

template<class S, typename = std::enable_if<std::is_pointer<S>::value>>
inline const S as() const

Casts stored object to any provided type.

Uses reinterpret_cast.

Template Parameters

S – Type to be casted to

Returns

Casted to the given type const object

Friends

inline friend bool operator==(const T *pointer, const LockedMemory<T> &lm)

Compares the object with the one stored in the memory.

Parameters
  • pointer – A pointer to compare with

  • lm – A compared LockedMemory object

Returns

true if objects are equal, false otherwise