libMesh::Singleton Class Reference

Base class for all library singleton objects. More...

#include <libmesh_singleton.h>

Inheritance diagram for libMesh::Singleton:

Classes

class  Setup
 

Static Public Member Functions

static void setup ()
 
static void cleanup ()
 

Protected Member Functions

 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

Base class for all library singleton objects.

Base class for all library singleton objects.

Author
Benjamin S. Kirk
Date
2013

Definition at line 35 of file libmesh_singleton.h.

Constructor & Destructor Documentation

libMesh::Singleton::Singleton ( )
protected

Constructor. Adds the derived object to the singleton cache list.

Definition at line 64 of file libmesh_singleton.C.

65 {
66  SingletonMutex::scoped_lock lock(singleton_mtx);
67 
68  get_singleton_cache().push_back (this);
69 }
virtual libMesh::Singleton::~Singleton ( )
inlineprotectedvirtual

Destructor.

Definition at line 47 of file libmesh_singleton.h.

47 {}

Member Function Documentation

void libMesh::Singleton::cleanup ( )
static

Cleanup function. Removes all dynamically created Singleton objects.

Definition at line 96 of file libmesh_singleton.C.

References libMesh::libmesh_assert(), and libmesh_nullptr.

Referenced by libMesh::LibMeshInit::LibMeshInit(), and libMesh::Singleton::Setup::~Setup().

97 {
98  SingletonMutex::scoped_lock lock(singleton_mtx);
99 
100  SingletonList & singleton_cache = get_singleton_cache();
101 
102  for (SingletonList::reverse_iterator it = singleton_cache.rbegin();
103  it!=singleton_cache.rend(); ++it)
104  {
106  delete *it;
107  *it = libmesh_nullptr;
108  }
109 
110  singleton_cache.clear();
111 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
void libMesh::Singleton::setup ( )
static

Setup function. Initializes any derived Singleton::Setup objects. objects.

Definition at line 80 of file libmesh_singleton.C.

References libMesh::libmesh_assert(), and libmesh_nullptr.

Referenced by libMesh::LibMeshInit::LibMeshInit().

81 {
82  SingletonMutex::scoped_lock lock(setup_mtx);
83 
84  SetupList & setup_cache = get_setup_cache();
85 
86  for (SetupList::iterator it = setup_cache.begin();
87  it!=setup_cache.end(); ++it)
88  {
90  (*it)->setup();
91  }
92 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)

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