TSDuck v3.40-4033
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::PollFiles Class Reference

A class to poll files for modifications. More...

#include <tsPollFiles.h>

Public Member Functions

 PollFiles ()=default
 Default constructor.
 
template<class Rep1 , class Period1 , class Rep2 , class Period2 >
 PollFiles (const UString &wildcard, PollFilesListener *listener=nullptr, const cn::duration< Rep1, Period1 > &poll_interval=DEFAULT_POLL_INTERVAL, const cn::duration< Rep2, Period2 > &min_stable_delay=DEFAULT_MIN_STABLE_DELAY, Report &report=(ts::CerrReport::Instance()))
 Constructor.
 
bool pollOnce ()
 Perform one poll operation, notify listener if necessary, and return immediately.
 
void pollRepeatedly ()
 Poll files continuously until the listener asks to terminate.
 
void setFileWildcard (const UString &wildcard)
 Set a new file wildcard specification to poll.
 
void setListener (PollFilesListener *listener)
 Set a new file listener.
 
template<class Rep , class Period >
void setMinStableDelay (const cn::duration< Rep, Period > &min_stable_delay)
 Set a new minimum file stability delay.
 
template<class Rep , class Period >
void setPollInterval (const cn::duration< Rep, Period > &poll_interval)
 Set a new polling interval.
 

Static Public Attributes

static constexpr cn::milliseconds DEFAULT_MIN_STABLE_DELAY = cn::milliseconds(500)
 Default minimum file stability delay.
 
static constexpr cn::milliseconds DEFAULT_POLL_INTERVAL = cn::milliseconds(1000)
 Default interval between two poll operations.
 

Detailed Description

A class to poll files for modifications.

Constructor & Destructor Documentation

◆ PollFiles()

template<class Rep1 , class Period1 , class Rep2 , class Period2 >
ts::PollFiles::PollFiles ( const UString wildcard,
PollFilesListener listener = nullptr,
const cn::duration< Rep1, Period1 > &  poll_interval = DEFAULT_POLL_INTERVAL,
const cn::duration< Rep2, Period2 > &  min_stable_delay = DEFAULT_MIN_STABLE_DELAY,
Report report = (ts::CerrReport::Instance()) 
)
inline

Constructor.

Parameters
[in]wildcardWildcard specification of files to poll (eg "/path/to/*.dat").
[in]listenerInvoked on file modification. Can be null.
[in]poll_intervalInterval between two poll operations.
[in]min_stable_delayA file size needs to be stable during that duration for the file to be reported as added or modified. This prevent too frequent poll notifications when a file is being written and his size modified at each poll.
[in,out]reportFor debug messages only.

Member Function Documentation

◆ setFileWildcard()

void ts::PollFiles::setFileWildcard ( const UString wildcard)
inline

Set a new file wildcard specification to poll.

Parameters
[in]wildcardWildcard specification of files to poll (eg "/path/to/*.dat").

◆ setListener()

void ts::PollFiles::setListener ( PollFilesListener listener)
inline

Set a new file listener.

Parameters
[in]listenerInvoked on file modification. Can be null.

◆ setPollInterval()

template<class Rep , class Period >
void ts::PollFiles::setPollInterval ( const cn::duration< Rep, Period > &  poll_interval)
inline

Set a new polling interval.

Parameters
[in]poll_intervalInterval in milliseconds between two poll operations.

◆ setMinStableDelay()

template<class Rep , class Period >
void ts::PollFiles::setMinStableDelay ( const cn::duration< Rep, Period > &  min_stable_delay)
inline

Set a new minimum file stability delay.

Parameters
[in]min_stable_delayA file size needs to be stable during that duration for the file to be reported as added or modified. This prevent too frequent poll notifications when a file is being written and his size modified at each poll.

◆ pollRepeatedly()

void ts::PollFiles::pollRepeatedly ( )

Poll files continuously until the listener asks to terminate.

Invoke the listener each time something has changed. The first time, all files are reported as "added".

◆ pollOnce()

bool ts::PollFiles::pollOnce ( )

Perform one poll operation, notify listener if necessary, and return immediately.

Returns
True to continue polling, false to exit polling.

Member Data Documentation

◆ DEFAULT_MIN_STABLE_DELAY

constexpr cn::milliseconds ts::PollFiles::DEFAULT_MIN_STABLE_DELAY = cn::milliseconds(500)
staticconstexpr

Default minimum file stability delay.

A file size needs to be stable during that duration for the file to be reported as added or modified. This prevent too frequent poll notifications when a file is being written and his size modified at each poll.


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