Celeritas 0.6.0-93+develop.7a7d9941
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
celeritas::test::PersistentSP< T > Class Template Reference

Hold a shared pointer across test cases and clean at teardown. More...

#include <PersistentSP.hh>

Public Types

Type aliases
using SP = std::shared_ptr< T >
 

Public Member Functions

 PersistentSP (std::string &&desc)
 Register the environment on construction.
 
 operator bool () const
 Whether a value is stored.
 
void set (std::string &&key, SP &&ptr)
 Replace the pointer.
 
void clear ()
 Clear stored value.
 
std::string constkey () const
 Access the key (empty if unset)
 
SP constvalue () const
 Access the pointer (null if unset)
 

Detailed Description

template<class T>
class celeritas::test::PersistentSP< T >

Hold a shared pointer across test cases and clean at teardown.

Keep a static instance of this class inside a test harness (or anywhere); it will register a cleanup function in GoogleTest that will fire before the end of the program.

This is needed to manage persistent objects that use static storage duration, such as VecGeom. For those cases, a static object that cleans up VecGeom on teardown may be called after VecGeom's static destructors, since static initialization/destruction order is undefined across translation units.


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