... | @@ -4,7 +4,7 @@ A singleton is a class that can be **instantiated only once**: this can be very |
... | @@ -4,7 +4,7 @@ A singleton is a class that can be **instantiated only once**: this can be very |
|
|
|
|
|
In boardcore, you can achieve this by extending the Singleton template which you can find in `src/shared/`.
|
|
In boardcore, you can achieve this by extending the Singleton template which you can find in `src/shared/`.
|
|
|
|
|
|
### Interface
|
|
## Methods
|
|
The Singleton interface is a template class which exposes a single method:
|
|
The Singleton interface is a template class which exposes a single method:
|
|
```cpp
|
|
```cpp
|
|
inline static T* getInstance()
|
|
inline static T* getInstance()
|
... | @@ -17,7 +17,7 @@ What this method does is: |
... | @@ -17,7 +17,7 @@ What this method does is: |
|
- If an instance of this class already exists, return that instance.
|
|
- If an instance of this class already exists, return that instance.
|
|
- If an instance of this class does not exist yet, create and return a new one.
|
|
- If an instance of this class does not exist yet, create and return a new one.
|
|
|
|
|
|
### Example
|
|
## Example
|
|
|
|
|
|
From the `Singleton.h` comment:
|
|
From the `Singleton.h` comment:
|
|
```cpp
|
|
```cpp
|
... | | ... | |