libMesh::Singleton Class Reference

#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.

Definition at line 30 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 42 of file libmesh_singleton.h.

42 {}

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().

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  {
105  libmesh_assert (*it != NULL);
106  delete *it;
107  *it = NULL;
108  }
109 
110  singleton_cache.clear();
111  }
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().

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  {
89  libmesh_assert (*it != NULL);
90  (*it)->setup();
91  }
92  }

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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:01 UTC

Hosted By:
SourceForge.net Logo