// $Id$
//
-// Copyright (C) 2007
-// Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
/** \file
\brief singleton public header */
-#ifndef HH_singleton_
-#define HH_singleton_ 1
+#ifndef HH_SENF_Utils_singleton_
+#define HH_SENF_Utils_singleton_ 1
// Custom includes
#include <boost/utility.hpp>
: public senf::singleton<SomeClass>
{
// Must have default constructor
- SomeClass();
-
+ SomeClass();
+
// Give singleton access to the constructor
friend class senf::singleton<SomeClass>;
public:
// By default 'instance()' is protected. If you want, you may make it public:
using senf::singleton<SomeClass>::instance;
-
+
// ...
};
SomeClass::instance().doSomething();
}
\endcode
-
+
\warning The singleton class should \e not have any static data members since it cannot be
guaranteed, that these members will be constructed before the singleton instance.
: boost::noncopyable
{
protected:
+ singleton();
+ ~singleton();
+
static Self & instance(); ///< Return singleton instance
+ static bool alive(); ///< Return \c true, if instance ok, \c false otherwise
private:
/** \brief Internal
\internal
*/
- struct force_creation
+ struct force_creation
{
force_creation();
void nop() const;
};
static force_creation creator_;
+ static bool alive_;
};
}