SingletonLifetimePolicies.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00030 //----------------------------------------------------------------------
00031 #ifndef ICL_CORE_SINGLETON_LIFETIME_POLICIES_H_INCLUDED
00032 #define ICL_CORE_SINGLETON_LIFETIME_POLICIES_H_INCLUDED
00033 
00034 #include <stdlib.h>
00035 #include <stdexcept>
00036 
00037 namespace icl_core {
00038 
00040 typedef void (*DestructionFuncPtr)();
00041 
00047 template
00048 <class T>
00049 class SLPDefaultLifetime
00050 {
00051 public:
00052   static void scheduleDestruction(DestructionFuncPtr f)
00053   {
00054     atexit(f);
00055   }
00056 
00057   static void onDeadReference()
00058   {
00059     throw std::logic_error("attempted to access a singleton instance after its destruction");
00060   }
00061 };
00062 
00068 template
00069 <class T>
00070 class SLPNoDestroy
00071 {
00072 public:
00073   static void scheduleDestruction(DestructionFuncPtr)
00074   {
00075   }
00076 
00077   static void onDeadReference()
00078   {
00079   }
00080 };
00081 
00082 }
00083 
00084 #endif


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19