Cbeam
Loading...
Searching...
No Matches
cbeam::container Namespace Reference

Offers advanced container types with unique approaches to stability and interprocess sharing. Besides standard helpers like buffer and circular_buffer, it includes innovative classes such as stable_interprocess_container and stable_interprocess_map. These support shared-memory usage, ensuring consistent serialization and robust data exchange across process boundaries or differing compiler environments. More...

Namespaces

namespace  xpod
 Provides a specialized variant type (xpod::type) for simple data exchange, supporting integer, floating-point, boolean, pointers, and strings. This namespace is designed for compactness and serializability, letting you store fundamental data types in a variant structure. By including additional headers, the variant gains transparent serialization capabilities without sacrificing performance.
 

Classes

class  buffer
 Manages memory a byte buffer, offering dynamic appending. This class is designed for scenarios where performance and control are crucial, such as in systems with dynamic memory requirements or real-time constraints. It uses malloc and free for efficient resizing of memory blocks without initialization overhead, as it internally uses the plain data type uint8_t. More...
 
class  circular_buffer
 A template class representing a circular buffer. More...
 
struct  nested_map
 A map structure that can store nested maps of keys and values. By including serialization/nested_map.hpp, it gains serialization capability. More...
 
class  stable_interprocess_container
 Manages type-safe, interprocess container operations with stable serialization. More...
 
class  stable_interprocess_map
 Provides a type-safe, interprocess map with stable serialization. More...
 
class  stable_reference_buffer
 Manages memory buffers with stable reference counting, optimized for shared library contexts. More...
 
class  thread_safe_container
 Base class for thread safe containers. More...
 
class  thread_safe_map
 Thread-safe wrapper for std::map. More...
 
class  thread_safe_set
 Thread-safe wrapper for std::set. More...
 

Functions

template<typename Key, typename Value, typename... VariantTypes>
bool key_exists (const std::map< std::variant< VariantTypes... >, Value > &t, const Key &key)
 Checks if a std::map using std::variant as a key contains a specific key.
 
template<typename T, typename... Types>
get_value_or_default (const std::variant< Types... > &value) noexcept
 
template<std::size_t T, typename... Types>
auto get_value_or_default (const std::variant< Types... > &value) noexcept
 
template<typename Key, typename Value>
bool operator== (const nested_map< Key, Value > &lhs, const nested_map< Key, Value > &rhs)
 
template<typename T>
std::shared_ptr< T > make_shared_array (const size_t size)
 Creates a std::shared_ptr that manages a dynamically allocated array of size size.
 
 TEST (CircularBuffer, TestDefaultConstructor)
 
 TEST (CircularBuffer, TestPushBack)
 
 TEST (CircularBuffer, TestEmplaceBack)
 
 TEST (CircularBuffer, TestElementAccess)
 
 TEST (CircularBuffer, TestBeginEnd)
 
 TEST (CircularBuffer, TestClear)
 
 TEST (CircularBuffer, TestOverflow)
 

Detailed Description

Offers advanced container types with unique approaches to stability and interprocess sharing. Besides standard helpers like buffer and circular_buffer, it includes innovative classes such as stable_interprocess_container and stable_interprocess_map. These support shared-memory usage, ensuring consistent serialization and robust data exchange across process boundaries or differing compiler environments.

Function Documentation

◆ get_value_or_default() [1/2]

template<typename T, typename... Types>
T cbeam::container::get_value_or_default ( const std::variant< Types... > & value)
noexcept

Returns the value of type T in the std::variant, if it is available, otherwise the default value of T

Template Parameters
Tthe type that shall be retrieved from the given std::variant instance
Typesthe types of the std::variant value
Parameters
valuethe std::variant to read from
Returns
If the value at type index T in the std::variant instance does exist, returns it, otherwise (if its does not exist or the type is not available in the std::variant) the default value of the corresponding type.

◆ get_value_or_default() [2/2]

template<std::size_t T, typename... Types>
auto cbeam::container::get_value_or_default ( const std::variant< Types... > & value)
noexcept

Returns the value at type index T of the given std::variant instance. If the value is not set in the std::variant or T is a type index that is not available in the std::variant instance, the default value of the corresponding type will be returned.

Template Parameters
Tthe type index to be accessed in the value
Typesthe types of the std::variant value
Parameters
valuethe std::variant to read from
Returns
if the value at type index T in the std::variant instance does exist, returns it, otherwise (if its does not exist or the type index is not available in the std::variant) the default value of the corresponding type.

◆ key_exists()

template<typename Key, typename Value, typename... VariantTypes>
bool cbeam::container::key_exists ( const std::map< std::variant< VariantTypes... >, Value > & t,
const Key & key )

Checks if a std::map using std::variant as a key contains a specific key.

This function searches a std::map whose keys are comprised of a std::variant of different types, determining whether a specific key is present. It is generic and can be used for any combination of variants and keys.

Template Parameters
KeyThe type of the key being searched. Must be one of the VariantTypes.
ValueThe value type of the std::map, which is irrelevant for this function.
VariantTypesThe types of the std::variant used as the key type for the std::map.
Parameters
tThe std::map to be searched.
keyThe key to be searched for in t.
Returns
true if t contains a key-value pair with the given key, otherwise false.

◆ make_shared_array()

template<typename T>
std::shared_ptr< T > cbeam::container::make_shared_array ( const size_t size)
inline

Creates a std::shared_ptr that manages a dynamically allocated array of size size.

This function returns a std::shared_ptr<T> that holds an array of type T. The custom deleter ensures the array is deleted with delete[].

Template Parameters
TThe array element type.
Parameters
sizeThe number of elements in the array.
Returns
std::shared_ptr<T> A smart pointer to a dynamically allocated array.

◆ operator==()

template<typename Key, typename Value>
bool cbeam::container::operator== ( const nested_map< Key, Value > & lhs,
const nested_map< Key, Value > & rhs )
inline

◆ TEST() [1/7]

cbeam::container::TEST ( CircularBuffer ,
TestBeginEnd  )

◆ TEST() [2/7]

cbeam::container::TEST ( CircularBuffer ,
TestClear  )

◆ TEST() [3/7]

cbeam::container::TEST ( CircularBuffer ,
TestDefaultConstructor  )

◆ TEST() [4/7]

cbeam::container::TEST ( CircularBuffer ,
TestElementAccess  )

◆ TEST() [5/7]

cbeam::container::TEST ( CircularBuffer ,
TestEmplaceBack  )

◆ TEST() [6/7]

cbeam::container::TEST ( CircularBuffer ,
TestOverflow  )

◆ TEST() [7/7]

cbeam::container::TEST ( CircularBuffer ,
TestPushBack  )