ddt 1.2.1
Loading...
Searching...
No Matches
List of all members
ddt::DdtMemoryManager Class Reference

#include <ddtMemoryManager.hpp>

Inheritance diagram for ddt::DdtMemoryManager:
DdtMemoryManagerFake
 DdtMemoryManager (DdtLogger *logger, const std::string broker_port)
 
virtual ~DdtMemoryManager ()
 
int32_t CreateSharedMemory (const std::string data_stream_identifier, const int32_t max_data_sample_size, const int32_t number_of_samples)
 
bool DeleteSharedMemory (const std::string data_stream_identifier)
 
bool CheckIfShmExists (const std::string data_stream_identifier)
 
int32_t get_max_data_sample_size (const std::string data_stream_identifier)
 
int32_t get_number_of_samples (const std::string data_stream_identifier)
 
DdtMemoryAccessorget_memory_accessor (const std::string data_stream_identifier)
 
std::string get_shm_id (const std::string data_stream_identifier) const
 
std::string get_shm_full_path (const std::string data_stream_identifier) const
 
int32_t GetMaxPossibleBufferSize (const int32_t max_data_sample_size)
 
bool CheckSpaceAvailability (const int32_t max_data_sample_size, const int buffer_size)
 
const uint64_t GetAvailableSpace ()
 

Detailed Description

This class manages the handling of shared memories.

Constructor & Destructor Documentation

◆ DdtMemoryManager()

DdtMemoryManager::DdtMemoryManager ( DdtLogger * logger,
const std::string broker_port )

Constructor

Parameters
loggerA DDT logger object (no transfer of ownership).
broker_portThe port from the broker. Will be part of the shm identifier.

◆ ~DdtMemoryManager()

DdtMemoryManager::~DdtMemoryManager ( )
virtualdefault

Destructor

Member Function Documentation

◆ CheckIfShmExists()

bool DdtMemoryManager::CheckIfShmExists ( const std::string data_stream_identifier)

Checks if the shared memory specified by data stream identifier already exists in the shm_map.

Parameters
data_stream_identifierThe data stream identifier.
Returns
True if shared memory exists, false if not.

◆ CheckSpaceAvailability()

bool DdtMemoryManager::CheckSpaceAvailability ( const int32_t max_data_sample_size,
const int buffer_size )
protected

Checks if the requested space is available on the system.

Parameters
max_data_sample_sizeThe maximum data sample size.
buffer_sizeBuffer size specified by the user.
Returns
True if the requested space is available, false if not.

◆ CreateSharedMemory()

int32_t DdtMemoryManager::CreateSharedMemory ( const std::string data_stream_identifier,
const int32_t max_data_sample_size,
const int32_t number_of_samples )

Creates a Boost shared memory object and constructs a circular buffer. For each shared memory an accessor is created.

Parameters
data_stream_identifierThe data stream identifier.
max_data_sample_sizeThe maximum data sample size.
number_of_samplesThe Number of samples stored in the SHM ring buffer.
Return values
MEMORY_ERRORNot enough memory.
-1General error.
1Success.

◆ DeleteSharedMemory()

bool DdtMemoryManager::DeleteSharedMemory ( const std::string data_stream_identifier)

Removes the shared memory and updates the shm map and the SharedMemories.txt file.

Parameters
data_stream_identifierThe data stream identifier.
Returns
True if shared memory was successfully deleted, false if not.

◆ get_max_data_sample_size()

int32_t DdtMemoryManager::get_max_data_sample_size ( const std::string data_stream_identifier)

Returns max_data_sample_size.

Parameters
data_stream_identifierThe data stream identifier.
Returns
The maximum data sample size.

◆ get_memory_accessor()

DdtMemoryAccessor * DdtMemoryManager::get_memory_accessor ( const std::string data_stream_identifier)

Returns memory_accessor.

Parameters
data_stream_identifierThe data stream identifier.
Returns
The accessor to the shared memory.

◆ get_number_of_samples()

int32_t DdtMemoryManager::get_number_of_samples ( const std::string data_stream_identifier)

Returns number_of_samples.

Parameters
data_stream_identifierThe data stream identifier.
Returns
The Number of samples stored in the SHM ring buffer.

◆ get_shm_full_path()

std::string DdtMemoryManager::get_shm_full_path ( const std::string data_stream_identifier) const

Returns a full path to the shm file.

Parameters
data_stream_identifierThe data stream identifier.
Returns
The full path to the shm file.

◆ get_shm_id()

std::string DdtMemoryManager::get_shm_id ( const std::string data_stream_identifier) const

Returns a string combination of port and data stream identifier which is the shm identifier.

Parameters
data_stream_identifierThe data stream identifier.
Returns
The SHM identifier.

the shm id is created based on the data stream identifier and the port example: ddt-5001_ds1

◆ GetAvailableSpace()

const uint64_t DdtMemoryManager::GetAvailableSpace ( )
protected

Reads the available space on /dev/shm using the linux df command.

Returns
Available space in bytes.

create the linux command example: df /dev/shm | grep /dev/shm 2>&1

◆ GetMaxPossibleBufferSize()

int32_t DdtMemoryManager::GetMaxPossibleBufferSize ( const int32_t max_data_sample_size)

Computes the maximum possible number of buffer elements.

Parameters
max_data_sample_sizeThe maximum data sample size.
Returns
The maximum possible number of buffer elements.

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