---
name: "corelinux_Singleton"
section: "3"
platform: "linux"
package: "libcorelinux-dev"
version: "0.4.32-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/corelinux_Singleton"
---

# corelinux\_Singleton(3)

Ensure a class only has one instance, and provide a global point of access to it.

## NAME

corelinux::Singleton - Ensure a class only has one instance, and provide a global point of access to it.

## SYNOPSIS

`#include <Singleton.hpp>`

Inherits **corelinux::CoreLinuxObject**.

### Public Member Functions

**Singleton** (void)  throw ( Assertion )\
 *Default constructor sets theSingleton and theType after insuring that they are not already instantiated.*  **Singleton** (TypeImpl \*aTypePtr)  throw ( Assertion )\
 *Initializing constructor.*  virtual **~Singleton** (void)\
 *Virtual destructor.*  bool **operator==** (const  **Singleton** &aSingleton) const \
 *Equality operator tests that theSingleton instances are equal.*

### Static Public Member Functions

TypeImpl \* **instance** (void)\
 *Returns the instance of the TypeImpl.*

## Detailed Description

### template\<class TypeImpl\> class corelinux::Singleton\< TypeImpl \>

Ensure a class only has one instance, and provide a global point of access to it.

This is easier said than done outside of the solution domain. While we can declare a protocol by which the use of this type will prevent multiple applications, we can't insure that the implementor won't violate said protocol.

## Constructor & Destructor Documentation

### template\<class TypeImpl\> corelinux::Singleton\< TypeImpl \>::Singleton (void) throw ( Assertion )` [inline]`

Default constructor sets theSingleton and theType after insuring that they are not already instantiated. **Exceptions:**

*Assertion* .RE

## Member Function Documentation

### template\<class TypeImpl\> TypeImpl\* corelinux::Singleton\< TypeImpl \>::instance (void)` [inline, static]`

Returns the instance of the TypeImpl. **Returns:**

TypeImpl pointer

### template\<class TypeImpl\> bool corelinux::Singleton\< TypeImpl \>::operator== (const Singleton\< TypeImpl \> & aSingleton) const` [inline]`

Equality operator tests that theSingleton instances are equal. **Parameters:**

*Singleton* const reference

**Returns:**

bool true if equal

## Author

Generated automatically by Doxygen for CoreLinux++ from the source code.
