TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsPollFiles.h>

Public Member Functions

 PollFiles ()=default
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()))
bool pollOnce ()
void pollRepeatedly ()
void setFileWildcard (const UString &wildcard)
void setListener (PollFilesListener *listener)
template<class Rep, class Period>
void setMinStableDelay (const cn::duration< Rep, Period > &min_stable_delay)
template<class Rep, class Period>
void setPollInterval (const cn::duration< Rep, Period > &poll_interval)

Static Public Attributes

static constexpr cn::milliseconds DEFAULT_MIN_STABLE_DELAY = cn::milliseconds(500)
static constexpr cn::milliseconds DEFAULT_POLL_INTERVAL = cn::milliseconds(1000)

Detailed Description

A class to poll files for modifications.

Constructor & Destructor Documentation

◆ PollFiles() [1/2]

ts::PollFiles::PollFiles ( )
default

Default constructor

◆ PollFiles() [2/2]

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_POLL_INTERVAL

cn::milliseconds ts::PollFiles::DEFAULT_POLL_INTERVAL = cn::milliseconds(1000)
staticconstexpr

Default interval between two poll operations.

◆ DEFAULT_MIN_STABLE_DELAY

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: