NDDEM
Classes | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
cereal::detail::StaticObject< T > Class Template Reference

A static, pre-execution object. More...

#include <static_object.hpp>

Classes

class  LockGuard
 A class that acts like std::lock_guard. More...
 

Static Public Member Functions

static T & getInstance ()
 
static LockGuard lock ()
 Attempts to lock this static object for the current scope. More...
 

Private Member Functions

 StaticObject (StaticObject const &)
 

Static Private Member Functions

static T & create ()
 

Static Private Attributes

static T & instance = StaticObject<T>::create()
 

Detailed Description

template<class T>
class cereal::detail::StaticObject< T >

A static, pre-execution object.

This class will create a single copy (singleton) of some type and ensures that merely referencing this type will cause it to be instantiated and initialized pre-execution. For example, this is used heavily in the polymorphic pointer serialization mechanisms to bind various archive types with different polymorphic classes

Constructor & Destructor Documentation

◆ StaticObject()

template<class T >
cereal::detail::StaticObject< T >::StaticObject ( StaticObject< T > const )
inlineprivate

Member Function Documentation

◆ create()

template<class T >
static T& cereal::detail::StaticObject< T >::create ( )
inlinestaticprivate

Forces instantiation at pre-execution time

◆ getInstance()

template<class T >
static T& cereal::detail::StaticObject< T >::getInstance ( )
inlinestatic

◆ lock()

template<class T >
static LockGuard cereal::detail::StaticObject< T >::lock ( )
inlinestatic

Attempts to lock this static object for the current scope.

Note
This function is a no-op if cereal is not compiled with thread safety enabled (CEREAL_THREAD_SAFE = 1).

This function returns an object that holds a lock for this StaticObject that will release its lock upon destruction. This call will block until the lock is available.

Member Data Documentation

◆ instance

template<class T >
T & cereal::detail::StaticObject< T >::instance = StaticObject<T>::create()
staticprivate

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