Qore FilePoller Module Reference  0.1.0
FilePoller.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 /* FilePoller.qm Copyright (C) 2014 - 2016 Qore Technologies sro.
4 
5  Permission is hereby granted, free of charge, to any person obtaining a
6  copy of this software and associated documentation files (the "Software"),
7  to deal in the Software without restriction, including without limitation
8  the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  and/or sell copies of the Software, and to permit persons to whom the
10  Software is furnished to do so, subject to the following conditions:
11 
12  The above copyright notice and this permission notice shall be included in
13  all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  DEALINGS IN THE SOFTWARE.
22 */
23 
24 // make sure we have the required qore version
25 
26 
27 
28 
52 namespace FilePoller {
55  class FilePoller {
56 
57 public:
58  public :
59  const OrderAsc = 0;
60  const OrderDesc = 1;
61 
62  const SortNone = 0;
63  const SortName = 1;
64  const SortDate = 2;
65 
67  const Options = (
68  "log_info",
69  "log_detail",
70  "log_debug",
71  "poll_interval",
72  "reopt",
73  "sleep",
74  "sort_order",
75  "sort_type",
76  "start_thread",
77  );
78 
80  const RequiredKeys = (
81  "sleep",
82  "start_thread",
83  );
84 
85 public:
86 
87  private :
89  string path;
90 
92  string mask;
93 
95  int poll_interval = 10;
96 
98  bool runflag = False;
99 
101  bool fatal = False;
102 
104  int pollcnt = 0;
105 
107  int sort_type = SortName;
108 
110  int sort_order = OrderAsc;
111 
113  Mutex m();
114 
116  int tid;
117 
119  Counter sc();
120 
122  int reopt;
123 
125  *softint minage;
126 
128  *code log_info;
129 
131  *code log_detail;
132 
134  *code log_debug;
135 
138 
140  *code sleep;
141 
142 public:
143 
145 
166  constructor(string n_path, string n_mask, *hash n_opts);
167 
168 
170  destructor();
171 
172 
174 
189  list getFiles(int sort = FilePoller::SortNone, int order = FilePoller::OrderAsc);
190 
191 
193 
196  int start();
197 
198 
200 
208  stop();
209 
210 
212 
216  stopNoWait();
217 
218 
220 
227  waitStop();
228 
229 
231 
234  startInline();
235 
236 
238  bool runOnce();
239 
240 
242  private fileSleep(softint secs);
243 
244 
246  private run();
247 
248 
250  fileEvent(list files);
251 
252 
254 
266  abstract singleFileEvent(hash fih);
267 
269 
272  static checkPath(string path, string type, bool write = False);
273 
275  int getPollCount();
276 
277 
279  private logInfo(string fmt);
280 
281 
283  private logDetail(string fmt);
284 
285 
287  private logDebug(string fmt);
288 
289  };
290 };
291 // END
main module namespace
Definition: FilePoller.qm.dox.h:53
*code sleep
optional sleep closure
Definition: FilePoller.qm.dox.h:140
string mask
file name mask
Definition: FilePoller.qm.dox.h:92
*code log_info
optional info log closure
Definition: FilePoller.qm.dox.h:128
any sort(any arg)
const False
list list(...)
int tid
polling tid
Definition: FilePoller.qm.dox.h:116
string type(any arg)
*softint minage
minimum file age in seconds before the file will be included in the list returned ...
Definition: FilePoller.qm.dox.h:125
*code log_detail
optional detail log closure
Definition: FilePoller.qm.dox.h:131
*code log_debug
optional debug log closure
Definition: FilePoller.qm.dox.h:134
hash hash(object obj)
*code start_thread
optional start thread closure
Definition: FilePoller.qm.dox.h:137
string path
path to monitor
Definition: FilePoller.qm.dox.h:89
int reopt
regex options
Definition: FilePoller.qm.dox.h:122