X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2Fsingleton.hh;h=dce43c0e18f69d37041cb7a028e3ac09dfca64b1;hb=6a0836b7f462d3d77b79b35638cdbf4c9d4202fc;hp=8acb59b6753415767d76352230038090ee5e90cd;hpb=e8b91aa6a817af6d9a3714e7b66be6c0d6b0a4e5;p=senf.git diff --git a/Utils/singleton.hh b/Utils/singleton.hh index 8acb59b..dce43c0 100644 --- a/Utils/singleton.hh +++ b/Utils/singleton.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -55,15 +55,15 @@ namespace senf { : public senf::singleton { // Must have default constructor - SomeClass(); - + SomeClass(); + // Give singleton access to the constructor friend class senf::singleton; public: // By default 'instance()' is protected. If you want, you may make it public: using senf::singleton::instance; - + // ... }; @@ -74,7 +74,7 @@ namespace senf { 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. @@ -88,19 +88,24 @@ namespace senf { : 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_; }; }