dbp::singleton< T > Class Template Reference

Singleton class template. More...

#include <singleton.h>

Inheritance diagram for dbp::singleton< T >:
Inheritance graph
[legend]
Collaboration diagram for dbp::singleton< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool is_copy ()
 Check for instance copy.

Static Public Member Functions

static T & instance ()
 Obtain a singleton object reference.

Detailed Description

template<class T>
class dbp::singleton< T >

Singleton class template.

This class template is intended to provide singleton pattern. It is useful for development of classes that should be exist in one instance only.

Usage:

class test: public singleton<test> {
        friend class singleton<test>;
public:
        void foo();
        ...
};
...
test &t = test::instance();
t.foo();

Member Function Documentation

template<class T>
static T& dbp::singleton< T >::instance (  )  [inline, static]

Obtain a singleton object reference.

If the object was not instanceated, creates the instance. Returns the instance reference.

Returns:
the object instance reference
template<class T>
bool dbp::singleton< T >::is_copy (  )  [inline]

Check for instance copy.

If the instance is not created on instance() call, the instance is a copy.

Returns:
true if the instance was just created and false otherwise.

The documentation for this class was generated from the following file:

 
Support This Project
SourceForge.net Logo