CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | List of all members
CppCommon::SharedType< T > Class Template Reference

Shared memory type. More...

#include <shared_type.h>

Public Member Functions

 SharedType (const std::string &name)
 Create a new or open existing shared memory type with a given name. More...
 
 SharedType (const SharedType< T > &)=delete
 
 SharedType (SharedType< T > &&)=delete
 
 ~SharedType ()=default
 
SharedType< T > & operator= (const SharedType< T > &)=delete
 
SharedType< T > & operator= (SharedType< T > &&)=delete
 
 operator bool () const
 Check if the shared memory type is valid. More...
 
T & operator* ()
 Dereference shared memory type. More...
 
const T & operator* () const
 Dereference constant shared memory type. More...
 
T * operator-> ()
 Dereference shared memory type member. More...
 
const T * operator-> () const
 Dereference constant shared memory type member. More...
 
const std::string & name () const noexcept
 Get the shared memory type name. More...
 
size_t size () const noexcept
 Get the shared memory type size. More...
 
T * ptr ()
 Get the shared memory type pointer. More...
 
const T * ptr () const
 Get the constant shared memory type pointer. More...
 
T & ref ()
 Get the shared memory type reference. More...
 
const T & ref () const
 Get the constant shared memory type reference. More...
 
bool owner () const
 Get the shared memory type owner flag (true if the new one was created, false if the existing one was opened) More...
 

Detailed Description

template<typename T>
class CppCommon::SharedType< T >

Shared memory type.

Shared memory type allows to create an instance of the given type in a shared memory and access to the instance from multiple processes using the given name.

Not thread-safe.

Examples
system_shared_type.cpp.

Definition at line 27 of file shared_type.h.

Constructor & Destructor Documentation

◆ SharedType() [1/3]

template<typename T >
CppCommon::SharedType< T >::SharedType ( const std::string &  name)
inlineexplicit

Create a new or open existing shared memory type with a given name.

Parameters
name- Shared memory type name

Definition at line 12 of file shared_type.inl.

◆ SharedType() [2/3]

template<typename T >
CppCommon::SharedType< T >::SharedType ( const SharedType< T > &  )
delete

◆ SharedType() [3/3]

template<typename T >
CppCommon::SharedType< T >::SharedType ( SharedType< T > &&  )
delete

◆ ~SharedType()

template<typename T >
CppCommon::SharedType< T >::~SharedType ( )
default

Member Function Documentation

◆ name()

template<typename T >
const std::string& CppCommon::SharedType< T >::name ( ) const
inlinenoexcept

Get the shared memory type name.

Definition at line 56 of file shared_type.h.

◆ operator bool()

template<typename T >
CppCommon::SharedType< T >::operator bool ( ) const
inlineexplicit

Check if the shared memory type is valid.

Definition at line 43 of file shared_type.h.

◆ operator*() [1/2]

template<typename T >
T& CppCommon::SharedType< T >::operator* ( )
inline

Dereference shared memory type.

Definition at line 46 of file shared_type.h.

◆ operator*() [2/2]

template<typename T >
const T& CppCommon::SharedType< T >::operator* ( ) const
inline

Dereference constant shared memory type.

Definition at line 48 of file shared_type.h.

◆ operator->() [1/2]

template<typename T >
T* CppCommon::SharedType< T >::operator-> ( )
inline

Dereference shared memory type member.

Definition at line 51 of file shared_type.h.

◆ operator->() [2/2]

template<typename T >
const T* CppCommon::SharedType< T >::operator-> ( ) const
inline

Dereference constant shared memory type member.

Definition at line 53 of file shared_type.h.

◆ operator=() [1/2]

template<typename T >
SharedType<T>& CppCommon::SharedType< T >::operator= ( const SharedType< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
SharedType<T>& CppCommon::SharedType< T >::operator= ( SharedType< T > &&  )
delete

◆ owner()

template<typename T >
bool CppCommon::SharedType< T >::owner ( ) const
inline

Get the shared memory type owner flag (true if the new one was created, false if the existing one was opened)

Examples
system_shared_type.cpp.

Definition at line 71 of file shared_type.h.

◆ ptr() [1/2]

template<typename T >
T* CppCommon::SharedType< T >::ptr ( )
inline

Get the shared memory type pointer.

Definition at line 61 of file shared_type.h.

◆ ptr() [2/2]

template<typename T >
const T* CppCommon::SharedType< T >::ptr ( ) const
inline

Get the constant shared memory type pointer.

Definition at line 63 of file shared_type.h.

◆ ref() [1/2]

template<typename T >
T& CppCommon::SharedType< T >::ref ( )
inline

Get the shared memory type reference.

Definition at line 66 of file shared_type.h.

◆ ref() [2/2]

template<typename T >
const T& CppCommon::SharedType< T >::ref ( ) const
inline

Get the constant shared memory type reference.

Definition at line 68 of file shared_type.h.

◆ size()

template<typename T >
size_t CppCommon::SharedType< T >::size ( ) const
inlinenoexcept

Get the shared memory type size.

Definition at line 58 of file shared_type.h.


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