All Classes Namespaces Functions Variables Groups Pages
FilePoller.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* FilePoller.qm Copyright (C) 2014 - 2016 Qore Technologies sro.
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;
Mutex m();
int tid;
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);
private run();
fileEvent(list files);
abstract singleFileEvent(hash fih);
static checkPath(string path, string type, bool write = False);
int getPollCount();
private logInfo(string fmt);
private logDetail(string fmt);
private logDebug(string fmt);
};
};
// END
FilePoller::FilePoller::logDebug
private logDebug(string fmt)
calls the &quot;log_debug&quot; closure or call reference with verbose debugging information ...
FilePoller::FilePoller::run
private run()
starts the polling operation
FilePoller::FilePoller::Options
const Options
known constructor() options
Definition: FilePoller.qm.dox.h:67
FilePoller::FilePoller::RequiredKeys
const RequiredKeys
minimum required keys for all constructors
Definition: FilePoller.qm.dox.h:80
FilePoller::FilePoller::poll_interval
int poll_interval
poll interval in seconds
Definition: FilePoller.qm.dox.h:95
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::sleep
*code sleep
optional sleep closure
Definition: FilePoller.qm.dox.h:140
FilePoller::FilePoller::stop
stop()
stops the polling operation, returns when the polling operation has been stopped
FilePoller::FilePoller::fatal
bool fatal
internal fatal error flag
Definition: FilePoller.qm.dox.h:101
FilePoller::FilePoller::mask
string mask
file name mask
Definition: FilePoller.qm.dox.h:92
FilePoller::FilePoller::log_info
*code log_info
optional info log closure
Definition: FilePoller.qm.dox.h:128
FilePoller::FilePoller::logDetail
private logDetail(string fmt)
calls the &quot;log_detail&quot; closure or call reference with detail information
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)
sort
any sort(any arg)
False
const False
FilePoller::FilePoller::pollcnt
int pollcnt
internal poll counter
Definition: FilePoller.qm.dox.h:104
list
list list(...)
FilePoller::FilePoller::m
Mutex m()
start mutex
FilePoller::FilePoller::fileSleep
private fileSleep(softint secs)
sleeps for the specificed number of seconds
FilePoller::FilePoller::sort_type
int sort_type
file sort type
Definition: FilePoller.qm.dox.h:107
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:110
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::logInfo
private logInfo(string fmt)
calls the &quot;log_info&quot; closure or call reference with important information
FilePoller::FilePoller::waitStop
waitStop()
waits indefinitely for the polling operation to stop; if polling was not in progress then this method...
FilePoller::FilePoller::tid
int tid
polling tid
Definition: FilePoller.qm.dox.h:116
type
string type(any arg)
FilePoller::FilePoller
file polling class
Definition: FilePoller.qm.dox.h:55
FilePoller::FilePoller::runflag
bool runflag
run flag
Definition: FilePoller.qm.dox.h:98
FilePoller::FilePoller::start
int start()
starts polling in the background; returns the thread ID of the polling thread
FilePoller::FilePoller::sc
Counter sc()
stop counter
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:125
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:131
FilePoller::FilePoller::log_debug
*code log_debug
optional debug log closure
Definition: FilePoller.qm.dox.h:134
FilePoller::FilePoller::constructor
constructor(string n_path, string n_mask, *hash n_opts)
creates the object
hash
hash hash(object obj)
FilePoller::FilePoller::start_thread
*code start_thread
optional start thread closure
Definition: FilePoller.qm.dox.h:137
FilePoller::FilePoller::path
string path
path to monitor
Definition: FilePoller.qm.dox.h:89
FilePoller::FilePoller::reopt
int reopt
regex options
Definition: FilePoller.qm.dox.h:122
FilePoller::FilePoller::runOnce
bool runOnce()
runs a single poll (useful for checking for errors inline before starting a background thread) ...