TSDuck v3.43-4441
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::Features Class Reference

Repository of dynamically registered features. More...

#include <tsFeatures.h>

Classes

class  Register
 A class to register a feature of the application. More...
 

Public Types

using GetVersionFunc = UString(*)()
 Profile of a function return a version string for a feature.
 
using index_t = Names::int_t
 Each feature is assigned a unique positive number.
 
enum  Support {
  ALWAYS ,
  SUPPORTED ,
  UNSUPPORTED
}
 Describe the level of support for a feature. More...
 

Public Member Functions

std::list< std::pair< UString, UString > > getAllVersions ()
 Get the version of all features.
 
UString getVersion (const UString &option)
 Get the version of a feature, if supported.
 
UString getVersion (index_t index)
 Get the version of a feature, if supported.
 
bool isSupported (const UString &option)
 Check if a feature is supported.
 
bool isSupported (index_t index)
 Check if a feature is supported.
 
index_t registerFeature (const UString &option, const fs::path &library)
 Register a feature which is in another shared image.
 
index_t registerFeature (const UString &option, const UString &name, Support support, GetVersionFunc get_version)
 Register a feature.
 
const NamessupportEnum () const
 Enumeration of optional features.
 
const NamesversionEnum () const
 Enumeration of versioned features.
 

Static Public Member Functions

static FeaturesInstance ()
 Get the instance of the singleton of this class.
 

Detailed Description

Repository of dynamically registered features.

Member Enumeration Documentation

◆ Support

Describe the level of support for a feature.

Enumerator
ALWAYS 

Feature is always supported, may ask version but no need to ask if supported.

SUPPORTED 

Optional feature, currently supported.

UNSUPPORTED 

Optional feature, not supported.

Member Function Documentation

◆ Instance()

static Features & ts::Features::Instance ( )
static

Get the instance of the singleton of this class.

Returns
The instance of the singleton of this class.

◆ registerFeature() [1/2]

index_t ts::Features::registerFeature ( const UString option,
const UString name,
Support  support,
GetVersionFunc  get_version 
)

Register a feature.

Parameters
[in]optionFeature name as used in command line options.
[in]nameFeature name as used on display.
[in]supportLevel of support.
[in]get_versionFunction returning the version of the feature. Can be null (no identified version).
Returns
An index for the feature, as used in isSupported() or getVersion().

◆ registerFeature() [2/2]

index_t ts::Features::registerFeature ( const UString option,
const fs::path &  library 
)

Register a feature which is in another shared image.

If a feature with the same option name is already registered, do nothing. Otherwise, the library name is stored for later usage. The first time the feature is searched, the shared library is loaded. If the load succeeds and the initialization of the shared image registered a feature with the same name, the feature becomes defined. Otherwise, the feature is definitely marked as unsupported.

Parameters
[in]optionFeature name as used in command line options.
[in]libraryName of a shared image (typically without directory).
Returns
An index for the feature, as used in isSupported() or getVersion().

◆ supportEnum()

const Names & ts::Features::supportEnum ( ) const
inline

Enumeration of optional features.

Typically used to implement the --support command line option.

Returns
A constant reference to the enumeration description. All integer values are positive. For a given feature which is both optional and versioned, the same integer value is returned by supportEnum() and versionEnum().
See also
versionEnum()

◆ versionEnum()

const Names & ts::Features::versionEnum ( ) const
inline

Enumeration of versioned features.

Typically used to implement the --version command line option.

Returns
A constant reference to the enumeration description. All integer values are positive. For a given feature which is both optional and versioned, the same integer value is returned by supportEnum() and versionEnum().
See also
supportEnum()

◆ isSupported() [1/2]

bool ts::Features::isSupported ( index_t  index)

Check if a feature is supported.

Parameters
[in]indexIndex of the feature as returned in supportEnum().
Returns
True if the feature is supported.

◆ isSupported() [2/2]

bool ts::Features::isSupported ( const UString option)

Check if a feature is supported.

Parameters
[in]optionCommand line option of the feature.
Returns
True if the feature is supported.

◆ getVersion() [1/2]

UString ts::Features::getVersion ( index_t  index)

Get the version of a feature, if supported.

Parameters
[in]indexIndex of the feature as returned in versionEnum().
Returns
Feature version string. Empty string if the feature is not supported.

◆ getVersion() [2/2]

UString ts::Features::getVersion ( const UString option)

Get the version of a feature, if supported.

Parameters
[in]optionCommand line option of the feature.
Returns
Feature version string. Empty string if the feature is not supported.

◆ getAllVersions()

std::list< std::pair< UString, UString > > ts::Features::getAllVersions ( )

Get the version of all features.

Returns
A list of string pairs: feature name, feature version.

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