Scopira  20080306
singleton.h
1 
2 /*
3  * Copyright (c) 2004 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_TOOL_SINGLETON_H__
15 #define __INCLUDED_SCOPIRA_TOOL_SINGLETON_H__
16 
17 #include <assert.h>
18 
19 namespace scopira
20 {
21  namespace tool
22  {
23  template <class T> class singleton;
24  }
25 }
26 
38 template <class T> class scopira::tool::singleton
39 {
40  protected:
42 
43  public:
45  static T * instance(void) { return dm_instance; }
46 
47  protected:
49  singleton(T *here) {
50  assert(!dm_instance);
51  dm_instance = here;
52  }
54  ~singleton(void) {
55  assert(dm_instance);
56  dm_instance = 0;
57  }
58 
59  private:
60  static T * dm_instance;
61 };
62 
63 #endif
64 
Definition: singleton.h:23
Definition: archiveflow.h:20
~singleton(void)
dtor
Definition: singleton.h:54
static T * instance(void)
return instance
Definition: singleton.h:45
singleton(T *here)
ctor
Definition: singleton.h:49