rlmm::singleton< Client, Lock > Struct Template Reference
[Utilities]

#include <rlmm/util.hh>

Inheritance diagram for rlmm::singleton< Client, Lock >:

Inheritance graph
[legend]
Collaboration diagram for rlmm::singleton< Client, Lock >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<template< typename > class Client, typename Lock = single_thread>
struct rlmm::singleton< Client, Lock >

Utility class to implement singletons.

Sub classes will be singletons. In sub classes, the constructor should preferable be protected (or even private) - which, however, requires that the sub-class befriends this class template:

      template <typename Lock>
      class only : singleton<only,Lock>
      {
        template <template <typename> class C,typename L>
        friend class singleton;
        only() {}
        only(const only& o) {}
        only& operator=(const only& o) { return *this; }
        ...
      };
Parameters:
Client The sub class template
Lock The lock type.


Public Member Functions

virtual ~singleton ()

Static Public Member Functions

static client_typeinstance ()

Protected Types

typedef Lock lock_type
typedef Client< Lock > client_type
typedef guard< Lock > guard_type

Protected Member Functions

 singleton ()
 singleton (const singleton &o)
singletonoperator= (const singleton &o)

Static Protected Attributes

static client_type_instance = 0
static lock_type _lock


Member Typedef Documentation

template<template< typename > class Client, typename Lock = single_thread>
typedef Client<Lock> rlmm::singleton< Client, Lock >::client_type [protected]
 

Client type.

template<template< typename > class Client, typename Lock = single_thread>
typedef guard<Lock> rlmm::singleton< Client, Lock >::guard_type [protected]
 

Guard type.

Reimplemented in rlmm::basic_buffer< Lock >.

template<template< typename > class Client, typename Lock = single_thread>
typedef Lock rlmm::singleton< Client, Lock >::lock_type [protected]
 

Lock type.


Constructor & Destructor Documentation

template<template< typename > class Client, typename Lock = single_thread>
rlmm::singleton< Client, Lock >::singleton  )  [inline, protected]
 

Protected constructor.

template<template< typename > class Client, typename Lock = single_thread>
rlmm::singleton< Client, Lock >::singleton const singleton< Client, Lock > &  o  )  [inline, protected]
 

Protected copy constructor.

template<template< typename > class Client, typename Lock = single_thread>
virtual rlmm::singleton< Client, Lock >::~singleton  )  [inline, virtual]
 

Destructor.

Removes the singleton.


Member Function Documentation

template<template< typename > class Client, typename Lock = single_thread>
static client_type& rlmm::singleton< Client, Lock >::instance  )  [inline, static]
 

Returns:
A reference to the singleton. Client code should only access the class using this static member function

template<template< typename > class Client, typename Lock = single_thread>
singleton& rlmm::singleton< Client, Lock >::operator= const singleton< Client, Lock > &  o  )  [inline, protected]
 

Protected assignment operator.


Member Data Documentation

template<template< typename > class Client, typename Lock = single_thread>
Client< Lock > * rlmm::singleton< Client, Lock >::_instance = 0 [static, protected]
 

The singleton.

template<template< typename > class Client, typename Lock = single_thread>
Lock rlmm::singleton< Client, Lock >::_lock [static, protected]
 

The global lock.


The documentation for this struct was generated from the following file:
Top of page
Last update Fri Aug 26 15:19:53 2005
Christian Holm
Created by DoxyGen 1.4.4