summaryrefslogtreecommitdiff
path: root/src/stable/singleton.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/stable/singleton.h
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/singleton.h')
-rw-r--r--src/stable/singleton.h98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/stable/singleton.h b/src/stable/singleton.h
index 6fe2777..27d907d 100644
--- a/src/stable/singleton.h
+++ b/src/stable/singleton.h
@@ -12,57 +12,57 @@
12 12
13namespace Bu 13namespace Bu
14{ 14{
15 /** 15 /**
16 * Provides singleton functionality in a modular sort of way. Make this the 16 * Provides singleton functionality in a modular sort of way. Make this the
17 * base class of any other class and you immediately gain singleton 17 * base class of any other class and you immediately gain singleton
18 * functionality. Be sure to make your constructor and various functions use 18 * functionality. Be sure to make your constructor and various functions use
19 * intellegent scoping. Cleanup and instantiation are performed automatically 19 * intellegent scoping. Cleanup and instantiation are performed automatically
20 * for you at first use and program exit. There are two things that you must 20 * for you at first use and program exit. There are two things that you must
21 * do when using this template, first is to inherit from it with the name of 21 * do when using this template, first is to inherit from it with the name of
22 * your class filling in for T and then make this class a friend of your class. 22 * your class filling in for T and then make this class a friend of your class.
23 *@code 23 *@code
24 * // Making the Single Singleton: 24 * // Making the Single Singleton:
25 * class Single : public Singleton<Single> 25 * class Single : public Singleton<Single>
26 * { 26 * {
27 * friend class Singleton<Single>; 27 * friend class Singleton<Single>;
28 * protected: 28 * protected:
29 * Single(); 29 * Single();
30 * ... 30 * ...
31 * }; 31 * };
32 @endcode 32 @endcode
33 * You can still add public functions and variables to your new Singleton child 33 * You can still add public functions and variables to your new Singleton child
34 * class, but your constructor should be protected (hence the need for the 34 * class, but your constructor should be protected (hence the need for the
35 * friend decleration). 35 * friend decleration).
36 */ 36 */
37 template <class T> 37 template <class T>
38 class Singleton 38 class Singleton
39 { 39 {
40 protected: 40 protected:
41 /** 41 /**
42 * Private constructor. This constructor is empty but has a body so that 42 * Private constructor. This constructor is empty but has a body so that
43 * you can make your own override of it. Be sure that you're override is 43 * you can make your own override of it. Be sure that you're override is
44 * also protected. 44 * also protected.
45 */ 45 */
46 Singleton() {}; 46 Singleton() {};
47 47
48 private: 48 private:
49 /** 49 /**
50 * Copy constructor, defined so that you could write your own as well. 50 * Copy constructor, defined so that you could write your own as well.
51 */ 51 */
52 Singleton( const Singleton& ); 52 Singleton( const Singleton& );
53 53
54 public: 54 public:
55 /** 55 /**
56 * Get a handle to the contained instance of the contained class. It is 56 * Get a handle to the contained instance of the contained class. It is
57 * a reference. 57 * a reference.
58 *@returns A reference to the contained object. 58 *@returns A reference to the contained object.
59 */ 59 */
60 static T &getInstance() 60 static T &getInstance()
61 { 61 {
62 static T i; 62 static T i;
63 return i; 63 return i;
64 } 64 }
65 }; 65 };
66} 66}
67 67
68#endif 68#endif