matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
matioCpp::MatvarHandler::Ownership Class Reference

The Ownership class is used to define the ownership of a matvar. More...

#include <matioCpp/MatvarHandler.h>

Public Member Functions

 Ownership (std::weak_ptr< PointerInfo > pointerToDeallocate)
 Constructor. More...
 
 ~Ownership ()
 Destructor. More...
 
bool isOwning (matvar_t *test)
 Check if an input pointer is owned by this ownership object. More...
 
void own (matvar_t *owned, const MatvarHandler *owner, matioCpp::DeleteMode mode)
 Add a pointer to the list of owned pointers. More...
 
void drop (matvar_t *previouslyOwned)
 Drop a previously owned pointer and deleted if necessary. More...
 
void dropAll ()
 Drops all the previously owned pointers and free those that need to be deallocated, including the main one. More...
 

Detailed Description

The Ownership class is used to define the ownership of a matvar.

SharedMatvar and WeakMatvar have a shared_ptr and a weak_ptr to it respectively.

Definition at line 109 of file MatvarHandler.h.

Constructor & Destructor Documentation

◆ Ownership()

matioCpp::MatvarHandler::Ownership::Ownership ( std::weak_ptr< PointerInfo pointerToDeallocate)

Constructor.

Parameters
pointerToDeallocateA weak pointer toward the PointerInfo that contains the pointer to be freed.

Definition at line 110 of file MatvarHandler.cpp.

◆ ~Ownership()

matioCpp::MatvarHandler::Ownership::~Ownership ( )

Destructor.

Definition at line 116 of file MatvarHandler.cpp.

Member Function Documentation

◆ drop()

void matioCpp::MatvarHandler::Ownership::drop ( matvar_t *  previouslyOwned)

Drop a previously owned pointer and deleted if necessary.

Parameters
previouslyOwnedThe pointer that is not own anymore

Definition at line 146 of file MatvarHandler.cpp.

References std::unordered_map< K, T >::end(), std::unordered_map< K, T >::erase(), and std::unordered_map< K, T >::find().

◆ dropAll()

void matioCpp::MatvarHandler::Ownership::dropAll ( )

Drops all the previously owned pointers and free those that need to be deallocated, including the main one.

Definition at line 172 of file MatvarHandler.cpp.

References matioCpp::MatvarHandler::PointerInfo::DeletePointer().

◆ isOwning()

bool matioCpp::MatvarHandler::Ownership::isOwning ( matvar_t *  test)

Check if an input pointer is owned by this ownership object.

Parameters
testThe pointer to test
Returns
true if the ownership objects owns the pointer

Definition at line 121 of file MatvarHandler.cpp.

◆ own()

void matioCpp::MatvarHandler::Ownership::own ( matvar_t *  owned,
const MatvarHandler owner,
matioCpp::DeleteMode  mode 
)

Add a pointer to the list of owned pointers.

This will not be deallocated as it is supposed to be part of the matvar_t pointer stored in m_ptr.

Parameters
ownedThe pointer to be considered owned.
ownerThe owner of owned. It is necessary to define the dependency tree.
modeDefine how the owned variable has to be deleted

Definition at line 126 of file MatvarHandler.cpp.

References matioCpp::MatvarHandler::m_ptr, matioCpp::MatvarHandler::Dependency::mode, and matioCpp::MatvarHandler::Dependency::parent.


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