All Classes Namespaces Functions Variables Groups Pages
FilePoller.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* FilePoller.qm Copyright (C) 2014 - 2017 Qore Technologies s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// make sure we have the required qore version
namespace FilePoller {
class FilePoller {
public:
public :
const OrderAsc = 0;
const OrderDesc = 1;
const SortNone = 0;
const SortName = 1;
const SortDate = 2;
const Options = (
"log_info",
"log_detail",
"log_debug",
"poll_interval",
"reopt",
"sleep",
"sort_order",
"sort_type",
"start_thread",
);
const RequiredKeys = (
"sleep",
"start_thread",
);
public:
private :
string path;
string mask;
int poll_interval = 10;
bool runflag = False;
bool fatal = False;
int pollcnt = 0;
int sort_type = SortName;
int sort_order = OrderAsc;
Qore::Thread::Mutex m();
int tid;
Qore::Thread::Counter sc();
int reopt;
*softint minage;
*code log_info;
*code log_detail;
*code log_debug;
*code start_thread;
*code sleep;
public:
constructor(string n_path, string n_mask, *hash n_opts);
destructor();
list getFiles(int sort = FilePoller::SortNone, int order = FilePoller::OrderAsc);
int start();
stop();
stopNoWait();
waitStop();
startInline();
bool runOnce();
private:
fileSleep(softint secs);
public:
private:
run();
public:
fileEvent(list files);
abstract singleFileEvent(hash fih);
static checkPath(string path, string type, bool write = False);
int getPollCount();
private:
logInfo(string fmt);
public:
private:
logDetail(string fmt);
public:
private:
logDebug(string fmt);
public:
};
};
// END
FilePoller::FilePoller::Options
const Options
known constructor() options
Definition: FilePoller.qm.dox.h:72
FilePoller::FilePoller::RequiredKeys
const RequiredKeys
minimum required keys for all constructors
Definition: FilePoller.qm.dox.h:85
FilePoller::FilePoller::poll_interval
int poll_interval
poll interval in seconds
Definition: FilePoller.qm.dox.h:100
FilePoller::FilePoller::fileEvent
fileEvent(list files)
called for each poll event with a list of all files matched; calls singleFileEvent() on each file has...
FilePoller::FilePoller::destructor
destructor()
stops the polling operation if in progress and destroys the object
FilePoller::FilePoller::run
run()
starts the polling operation
FilePoller::FilePoller::fileSleep
fileSleep(softint secs)
sleeps for the specificed number of seconds
FilePoller::FilePoller::sleep
*code sleep
optional sleep closure
Definition: FilePoller.qm.dox.h:145
FilePoller::FilePoller::stop
stop()
stops the polling operation, returns when the polling operation has been stopped
Qore::Thread::Mutex
FilePoller::FilePoller::fatal
bool fatal
internal fatal error flag
Definition: FilePoller.qm.dox.h:106
FilePoller::FilePoller::mask
string mask
file name mask
Definition: FilePoller.qm.dox.h:97
FilePoller::FilePoller::log_info
*code log_info
optional info log closure
Definition: FilePoller.qm.dox.h:133
FilePoller::FilePoller::SortName
const SortName
sort by name
Definition: FilePoller.qm.dox.h:67
FilePoller::FilePoller::getFiles
list getFiles(int sort=FilePoller::SortNone, int order=FilePoller::OrderAsc)
returns a list of regular file hashes matching any file name mask set for the object ...
FilePoller::FilePoller::startInline
startInline()
starts the polling operation inline (not in a background thread)
False
const False
FilePoller::FilePoller::pollcnt
int pollcnt
internal poll counter
Definition: FilePoller.qm.dox.h:109
sort
auto sort(auto arg)
list
list list(...)
FilePoller::FilePoller::m
Qore::Thread::Mutex m()
start mutex
FilePoller::FilePoller::sort_type
int sort_type
file sort type
Definition: FilePoller.qm.dox.h:112
FilePoller::FilePoller::stopNoWait
stopNoWait()
stops the polling operation, returns immediately
FilePoller::FilePoller::getPollCount
int getPollCount()
returns the current poll count
FilePoller::FilePoller::sort_order
int sort_order
file sort order
Definition: FilePoller.qm.dox.h:115
FilePoller::FilePoller::logDebug
logDebug(string fmt)
calls the &quot;log_debug&quot; closure or call reference with verbose debugging information ...
FilePoller::FilePoller::singleFileEvent
abstract singleFileEvent(hash fih)
called for each matching file individually whenever matching files are polled with the list of matchi...
FilePoller::FilePoller::waitStop
waitStop()
waits indefinitely for the polling operation to stop; if polling was not in progress then this method...
FilePoller::FilePoller::SortNone
const SortNone
no sorting
Definition: FilePoller.qm.dox.h:65
FilePoller::FilePoller::tid
int tid
polling tid
Definition: FilePoller.qm.dox.h:121
Qore::Thread::Counter
FilePoller::FilePoller::logInfo
logInfo(string fmt)
calls the &quot;log_info&quot; closure or call reference with important information
FilePoller::FilePoller
file polling class
Definition: FilePoller.qm.dox.h:55
FilePoller::FilePoller::runflag
bool runflag
run flag
Definition: FilePoller.qm.dox.h:103
FilePoller::FilePoller::start
int start()
starts polling in the background; returns the thread ID of the polling thread
type
string type(auto arg)
FilePoller::FilePoller::minage
*softint minage
minimum file age in seconds before the file will be included in the list returned ...
Definition: FilePoller.qm.dox.h:130
FilePoller::FilePoller::SortDate
const SortDate
sort by date
Definition: FilePoller.qm.dox.h:69
FilePoller::FilePoller::OrderAsc
const OrderAsc
ascending sort order
Definition: FilePoller.qm.dox.h:60
FilePoller::FilePoller::checkPath
static checkPath(string path, string type, bool write=False)
checks a path on the local file system
FilePoller::FilePoller::log_detail
*code log_detail
optional detail log closure
Definition: FilePoller.qm.dox.h:136
FilePoller::FilePoller::log_debug
*code log_debug
optional debug log closure
Definition: FilePoller.qm.dox.h:139
FilePoller::FilePoller::sc
Qore::Thread::Counter sc()
stop counter
FilePoller::FilePoller::constructor
constructor(string n_path, string n_mask, *hash n_opts)
creates the object
FilePoller::FilePoller::logDetail
logDetail(string fmt)
calls the &quot;log_detail&quot; closure or call reference with detail information
hash
hash hash(object obj)
FilePoller::FilePoller::OrderDesc
const OrderDesc
descending sort order
Definition: FilePoller.qm.dox.h:62
FilePoller::FilePoller::start_thread
*code start_thread
optional start thread closure
Definition: FilePoller.qm.dox.h:142
FilePoller::FilePoller::path
string path
path to monitor
Definition: FilePoller.qm.dox.h:94
FilePoller::FilePoller::reopt
int reopt
regex options
Definition: FilePoller.qm.dox.h:127
FilePoller::FilePoller::runOnce
bool runOnce()
runs a single poll (useful for checking for errors inline before starting a background thread) ...