TSDuck v3.45-4686
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::OwnedObject Class Reference

General-purpose base class for objects with an "owner". More...

#include <tsOwnedObject.h>

Inheritance diagram for ts::OwnedObject:
Collaboration diagram for ts::OwnedObject:

Public Member Functions

 OwnedObject (Object *owner=nullptr)
 Constructor.
 
virtual ~OwnedObject () override
 Destructor.
 
bool isOwned ()
 Check if the object is owned.
 
template<class OBJECT >
requires std::derived_from<OBJECT, ts::Object>
bool isOwned ()
 Check if the object is owned by an object of a given type.
 
Objectowner ()
 Get the address of the optional "owner" object which was specified in the constructor.
 
template<class OBJECT >
requires std::derived_from<OBJECT, ts::Object>
OBJECT * owner ()
 Get the address of the "owner" object which was specified in the constructor.
 

Detailed Description

General-purpose base class for objects with an "owner".

An object A is "owned" when we associate this object with an "owner" object B during the contruction of A. This association cannot be modified. Typically, A is a member of B and B always has a (slightly) longer lifetime than A.

Constructor & Destructor Documentation

◆ OwnedObject()

ts::OwnedObject::OwnedObject ( Object owner = nullptr)
inline

Constructor.

Parameters
[in]ownerOptional address of an "owner" object, typically an instance of class containing this object.

Member Function Documentation

◆ owner() [1/2]

Object * ts::OwnedObject::owner ( )
inline

Get the address of the optional "owner" object which was specified in the constructor.

Returns
Address of the "owner" object or a null pointer if there was none.

◆ isOwned() [1/2]

bool ts::OwnedObject::isOwned ( )
inline

Check if the object is owned.

Returns
True if this object has an owner, false otherwise.

◆ owner() [2/2]

template<class OBJECT >
requires std::derived_from<OBJECT, ts::Object>
OBJECT * ts::OwnedObject::owner ( )

Get the address of the "owner" object which was specified in the constructor.

This template version requires that the owner objet is set and of type OBJECT, or some subclass of it. If there is no owner object or if it is not compatible with the template class OBJECT, this is a fatal error and the application is terminated.

Template Parameters
OBJECTA subclass of Object
Returns
Address of the "owner" object or a null pointer if there was none.

◆ isOwned() [2/2]

template<class OBJECT >
requires std::derived_from<OBJECT, ts::Object>
bool ts::OwnedObject::isOwned ( )
inline

Check if the object is owned by an object of a given type.

Template Parameters
OBJECTA subclass of Object
Returns
True if this object has an owner by an object of type OBJECT, false otherwise.

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