eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc::ManuallyConstructed< T > Class Template Reference

Allocates static storage for an object. More...

#include <erpc_manually_constructed.hpp>

Public Member Functions

void destroy (void)
 Invoke the object's destructor. More...
 
bool isUsed (void)
 Returns information if object is free or is used. More...
 
Object access
T * get (void)
 
const T * get (void) const
 
T * operator-> (void)
 
const T * operator-> (void) const
 
T & operator* (void)
 
const T & operator* (void) const
 
 operator T * (void)
 
 operator const T * (void) const
 
Explicit construction methods
void construct (void)
 
template<typename A1 >
void construct (const A1 &a1)
 
template<typename A1 , typename A2 >
void construct (const A1 &a1, const A2 &a2)
 
template<typename A1 , typename A2 , typename A3 >
void construct (const A1 &a1, const A2 &a2, const A3 &a3)
 
template<typename A1 , typename A2 , typename A3 , typename A4 >
void construct (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
 
template<typename A1 , typename A2 , typename A3 , typename A4 , typename A5 >
void construct (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
 
template<typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
void construct (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
 

Protected Attributes

uint64_t m_storage [(sizeof(T)+sizeof(uint64_t)-1)/sizeof(uint64_t)]
 Storage for the object. More...
 
bool m_isConstructed
 Track construct/destruct calls. More...
 

Detailed Description

template<class T>
class erpc::ManuallyConstructed< T >

Allocates static storage for an object.

This template class defines storage of the template class' size. Then it gives the user explicit control over construction and destruction of the object residing in that storage. This is useful for placing objects in unions, or other situations where you need static storage but want to delay the actual construction of the object.

Objects of this class will act as a pointer to the template argument class type. Of course, if the object has not yet been constructed then the behavior is undefined if the pointer to it is used.

Note that there is not a constructor or deconstructor. This is because members of unions cannot have constructors or deconstructors.

Instances of this template class are aligned to 8 bytes.

Member Function Documentation

template<class T >
void erpc::ManuallyConstructed< T >::destroy ( void  )
inline

Invoke the object's destructor.

Behavior is undefined if the objected was not previously initialized.

template<class T >
bool erpc::ManuallyConstructed< T >::isUsed ( void  )
inline

Returns information if object is free or is used.

Returns
true Object is constructed and used.
false Object wasn't constructed or it was destructed already.

Member Data Documentation

template<class T >
uint64_t erpc::ManuallyConstructed< T >::m_storage[(sizeof(T)+sizeof(uint64_t)-1)/sizeof(uint64_t)]
protected

Storage for the object.

An array of uint64 is used to get 8-byte alignment.

template<class T >
bool erpc::ManuallyConstructed< T >::m_isConstructed
protected

Track construct/destruct calls.

Based on this variable we can allow or forbid construct/destruct calls.


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