TSDuck Version 3.24-2000 (TSDuck - The MPEG Transport Stream Toolkit)
ts::PollFiles Class Reference

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

Public Member Functions

 PollFiles (const UString &wildcard=UString(), PollFilesListener *listener=nullptr, MilliSecond poll_interval=DEFAULT_POLL_INTERVAL, MilliSecond min_stable_delay=DEFAULT_MIN_STABLE_DELAY, Report &report=(*(static_cast< ts::Report *>(ts::CerrReport::Instance()))))
 Constructor. More...
 
bool pollOnce ()
 Perform one poll operation, notify listener if necessary, and return immediately. More...
 
void pollRepeatedly ()
 Poll files continuously until the listener asks to terminate. More...
 
void setFileWildcard (const UString &wildcard)
 Set a new file wildcard specification to poll. More...
 
void setListener (PollFilesListener *listener)
 Set a new file listener. More...
 
void setMinStableDelay (MilliSecond min_stable_delay)
 Set a new minimum file stability delay. More...
 
void setPollInterval (MilliSecond poll_interval)
 Set a new polling interval. More...
 

Static Public Attributes

static const MilliSecond DEFAULT_MIN_STABLE_DELAY = 500
 Default minimum file stability delay. More...
 
static const MilliSecond DEFAULT_POLL_INTERVAL = 1000
 Default interval in milliseconds between two poll operations.
 

Detailed Description

A class to poll files for modifications.

Constructor & Destructor Documentation

◆ PollFiles()

ts::PollFiles::PollFiles ( const UString wildcard = UString(),
PollFilesListener listener = nullptr,
MilliSecond  poll_interval = DEFAULT_POLL_INTERVAL,
MilliSecond  min_stable_delay = DEFAULT_MIN_STABLE_DELAY,
Report report = (*(static_cast< ts::Report *>(ts::CerrReport::Instance()))) 
)

Constructor.

Parameters
[in]wildcardWildcard specification of files to poll (eg "/path/to/*.dat").
[in]listenerInvoked on file modification. Can be null.
[in]poll_intervalInterval in milliseconds 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()

void ts::PollFiles::setPollInterval ( MilliSecond  poll_interval)
inline

Set a new polling interval.

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

◆ setMinStableDelay()

void ts::PollFiles::setMinStableDelay ( MilliSecond  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

const MilliSecond ts::PollFiles::DEFAULT_MIN_STABLE_DELAY = 500
static

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: