1 //===-- MIUtilSingletonBase.h -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MIUtilSingletonBase.h
13 // Overview: MI::ISingleton interface.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
27 // MI::ISingleton base class usage:
29 // class CMIDerivedClass
30 // : public MI::ISingleton< CMIDerivedClass >
32 // friend MI::ISingleton< CMIDerivedClass >;
36 // // From MI::ISingleton
37 // virtual bool Initialize( void );
38 // virtual bool Shutdown( void );
41 //++ ============================================================================
42 // Details: Base class for the singleton pattern.
43 // Gotchas: Derived class must specify MI::ISingleton<> as a friend class.
44 // Authors: Aidan Dodds 17/03/2014.
47 template< typename T >
52 // Return an instance of the derived class
53 static T & Instance( void )
55 // This will fail if the derived class has not
56 // declared itself to be a friend of MI::ISingleton
64 virtual bool Initialize( void ) = 0;
65 virtual bool Shutdown( void ) = 0;
67 /* dtor */ virtual ~ISingleton( void ) { };