|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Templated design pattern implementation for C++: singleton.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a></div>
<h1>singleton.h</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef TEMPLATE_PATTERNS_SINGLETON</span>
00002 <span class="preprocessor"></span><span class="preprocessor">#define TEMPLATE_PATTERNS_SINGLETON</span>
00003 <span class="preprocessor"></span>
00005
00006 <span class="keyword">namespace </span>template_patterns
00007 {
00009
<a name="l00015"></a><a class="code" href="classtemplate__patterns_1_1singleton.html">00015</a> <span class="keyword">template</span> <<span class="keyword">class</span> T> <span class="keyword">class </span><a class="code" href="classtemplate__patterns_1_1singleton.html">singleton</a>
00016 {
00017 <span class="keyword">public</span>:
00019
<a name="l00021"></a><a class="code" href="classtemplate__patterns_1_1singleton.html#a0">00021</a> T & <a class="code" href="classtemplate__patterns_1_1singleton.html#a0">instance</a>()
00022 {
00023 <span class="keyword">static</span> T object;
00024 <span class="keywordflow">return</span> object;
00025 }
00026
00028
<a name="l00031"></a><a class="code" href="classtemplate__patterns_1_1singleton.html#a1">00031</a> T & <a class="code" href="classtemplate__patterns_1_1singleton.html#a1">operator* </a>()
00032 {
00033 <span class="keywordflow">return</span> <a class="code" href="classtemplate__patterns_1_1singleton.html#a0">instance</a>();
00034 }
00035
00037
<a name="l00040"></a><a class="code" href="classtemplate__patterns_1_1singleton.html#a2">00040</a> <span class="keyword">const</span> & <a class="code" href="classtemplate__patterns_1_1singleton.html#a1">operator* </a>()<span class="keyword"> const</span>
00041 <span class="keyword"> </span>{
00042 <span class="keywordflow">return</span> &<a class="code" href="classtemplate__patterns_1_1singleton.html#a0">instance</a>();
00043 }
00044 };
00045
00046
00047 };
00048
00049
00050 <span class="preprocessor">#endif // TEMPLATE_PATTERNS_SINGLETON</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Feb 1 08:22:32 2006 for Templated design pattern implementation for C++ by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.