TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
tsSingletonManager.h File Reference

Helper for singleton definition. More...

Classes

class  ts::SingletonManager
 Helper for singleton definition. More...
 

Namespaces

 ts
 TSDuck namespace, containing all TSDuck classes and functions.
 

Macros

#define TS_DECLARE_SINGLETON(classname)
 Singleton class declaration. More...
 
#define TS_DEFINE_SINGLETON(fullclassname)
 Singleton class definition. More...
 

Detailed Description

Helper for singleton definition.

Macro Definition Documentation

◆ TS_DECLARE_SINGLETON

#define TS_DECLARE_SINGLETON (   classname)

Singleton class declaration.

The macro TS_DECLARE_SINGLETON must be used inside the singleton class declaration.

Parameters
classnameName of the singleton class, without namespace or outer class name.

Example code:

// File: MySingle.h
namespace foo {
class MySingle {
....

The class becomes a singleton, under control of the SingletonManager. Use static Instance() method to get the instance of the singleton.

See also
TS_DEFINE_SINGLETON()

◆ TS_DEFINE_SINGLETON

#define TS_DEFINE_SINGLETON (   fullclassname)

Singleton class definition.

The macro TS_DEFINE_SINGLETON must be used in the implementation of a singleton class.

Parameters
fullclassnameFully qualified name of the singleton class.

Example code:

// File: MySingle.cpp
#include "MySingle.h"
TS_DEFINE_SINGLETON(foo::MySingle);
foo::MySingle::MySingle() : ... { ... }
....
See also
TS_DECLARE_SINGLETON()