matio-cpp
v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
|
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... | |
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.
matioCpp::MatvarHandler::Ownership::Ownership | ( | std::weak_ptr< PointerInfo > | pointerToDeallocate | ) |
Constructor.
pointerToDeallocate | A weak pointer toward the PointerInfo that contains the pointer to be freed. |
Definition at line 110 of file MatvarHandler.cpp.
matioCpp::MatvarHandler::Ownership::~Ownership | ( | ) |
Destructor.
Definition at line 116 of file MatvarHandler.cpp.
void matioCpp::MatvarHandler::Ownership::drop | ( | matvar_t * | previouslyOwned | ) |
Drop a previously owned pointer and deleted if necessary.
previouslyOwned | The 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().
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().
bool matioCpp::MatvarHandler::Ownership::isOwning | ( | matvar_t * | test | ) |
Check if an input pointer is owned by this ownership object.
test | The pointer to test |
Definition at line 121 of file MatvarHandler.cpp.
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.
owned | The pointer to be considered owned. |
owner | The owner of owned. It is necessary to define the dependency tree. |
mode | Define 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.