diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-10-21 21:41:34 +0000 |
commit | a5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch) | |
tree | bcf0a25c3d45a209a6e3ac37b233a4812f29c732 /ace/Singleton.h | |
download | ATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz |
Initial revision
Diffstat (limited to 'ace/Singleton.h')
-rw-r--r-- | ace/Singleton.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ace/Singleton.h b/ace/Singleton.h new file mode 100644 index 00000000000..7761acf53c4 --- /dev/null +++ b/ace/Singleton.h @@ -0,0 +1,65 @@ +/* -*- C++ -*- */ +// $Id$ + + +// ============================================================================ +// +// = LIBRARY +// ace +// +// = FILENAME +// Singleton.h +// +// = DESCRIPTION +// +// = AUTHOR +// Tim Harrison (harrison@cs.wustl.edu) and Douglas C. Schmidt +// +// ============================================================================ + +#if !defined (ACE_SINGLETON_H) +#define ACE_SINGLETON_H + +#include "ace/ACE.h" + +template <class TYPE, class LOCK> +class ACE_Singleton + // = TITLE + // A Singleton Adapter. + // + // = DESCRIPTION + // Uses the Adapter pattern to turn ordinary classes into + // Singletons optimized with the Double-Check pattern. +{ +public: + static TYPE *instance (void); + // Global access point to the Singleton. + + void dump (void) const; + // Dump the state of the object. + +protected: +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + static TYPE *instance_; + // Pointer to the Singleton instance. + + static LOCK ace_singleton_lock_; + // Lock the creation of the singleton. +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +}; + +#if defined (__ACE_INLINE__) +#include "ace/Singleton.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Singleton.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Singleton.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_SINGLETON_H */ + + |