Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
projects:singleton_template [2015/11/15] – [Q & A] terence | projects:singleton_template [2016/07/05] (current) – July 5, 2016 terence | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Singleton Template (C++) ====== | ====== Singleton Template (C++) ====== | ||
+ | |||
+ | //An inheritance-based way to make singleton classes in C++// | ||
+ | |||
===== License ===== | ===== License ===== | ||
Line 5: | Line 8: | ||
* **Author:** [[mailto: | * **Author:** [[mailto: | ||
* **License: | * **License: | ||
- | * **Last Update:** 2015-11-15 | + | * **Last Update:** 2015-12-21 |
* **Donate:** [[: | * **Donate:** [[: | ||
Line 14: | Line 17: | ||
After downloading, | After downloading, | ||
- | FIXME | + | * Latest version: [[https:// |
===== About ===== | ===== About ===== | ||
- | FIXME | + | The Singleton Template is a [[wp> |
+ | This provides a few benefits over other techniques: | ||
+ | |||
+ | * Consistent method interface among all singletons (all singletons will have a **'':: | ||
+ | * Never having to copy / paste code for singleton creation (which is good if, for instance, best practices change) | ||
+ | |||
+ | The singleton creation method in **'':: | ||
===== How to Use ===== | ===== How to Use ===== | ||
Line 28: | Line 37: | ||
<code c++> | <code c++> | ||
- | #include "singleton.h" | + | #include "tSingleton.h" |
</ | </ | ||
* Create your own singleton class, ensuring that: | * Create your own singleton class, ensuring that: | ||
- | - You inherit from **'' | + | - You inherit from **'' |
- Your **constructor**' | - Your **constructor**' | ||
- Your **destructor** is **'' | - Your **destructor** is **'' | ||
Line 40: | Line 49: | ||
<code c++> | <code c++> | ||
class MyClass | class MyClass | ||
- | : public | + | : public |
{ | { | ||
protected: | protected: | ||
Line 53: | Line 62: | ||
//Methods go here | //Methods go here | ||
- | friend class tjgrant:: | + | friend class tSingleton< |
}; | }; | ||
</ | </ | ||
Line 89: | Line 98: | ||
//If you have a question not answered here, please feel free to [[mailto: | //If you have a question not answered here, please feel free to [[mailto: | ||
+ | |||
+ | === Inheritance? | ||
* **Q:** My class already inherits from another class; can I still use this? | * **Q:** My class already inherits from another class; can I still use this? | ||
Line 98: | Line 109: | ||
class MyClass | class MyClass | ||
: public MyBase, | : public MyBase, | ||
- | public | + | public |
</ | </ | ||
+ | |||
+ | === Thread Safety? === | ||
* **Q:** Is this library [[wp> | * **Q:** Is this library [[wp> | ||
Line 107: | Line 120: | ||
* //Note: That said, I would suggest only accessing **'':: | * //Note: That said, I would suggest only accessing **'':: | ||
- | * **Q:** Singletons / Templates / Multiple Inheritance is horrible and you shouldn' | + | If you've found this project useful, [[: |
- | * **A:** I disagree. Tools are tools, you're free to use them **or not use them** as you wish. | + | |
- | * //Note: If you really do feel this way, realize that these are your " | + | |
- | + | ||
- | //If you've found this project useful, [[: | + | |
===== History ===== | ===== History ===== | ||
- | **November 15, 2015** | + | **July 5, 2016** |
+ | * Removed the namespace, renamed class from " | ||
+ | |||
+ | **December 21, 2015** | ||
+ | |||
+ | * Added GitHub link to download section | ||
* First public release | * First public release | ||
+ | **November 15, 2015** | ||
+ | |||
+ | * Created project page |