$extrastylesheet
libMesh::Singleton Class Reference

#include <libmesh_singleton.h>

Inheritance diagram for libMesh::Singleton:

List of all members.

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

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

Definition at line 64 of file libmesh_singleton.C.

{
  SingletonMutex::scoped_lock lock(singleton_mtx);

  get_singleton_cache().push_back (this);
}
virtual libMesh::Singleton::~Singleton ( ) [inline, protected, virtual]

Destructor.

Definition at line 42 of file libmesh_singleton.h.

{}

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

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

{
  SingletonMutex::scoped_lock lock(singleton_mtx);

  SingletonList& singleton_cache = get_singleton_cache();

  for (SingletonList::reverse_iterator it = singleton_cache.rbegin();
       it!=singleton_cache.rend(); ++it)
    {
      libmesh_assert (*it != NULL);
      delete *it;
      *it = NULL;
    }

  singleton_cache.clear();
}
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().

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

{
  SingletonMutex::scoped_lock lock(setup_mtx);

  SetupList& setup_cache = get_setup_cache();

  for (SetupList::iterator it = setup_cache.begin();
       it!=setup_cache.end(); ++it)
    {
      libmesh_assert (*it != NULL);
      (*it)->setup();
    }
}

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