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 :
60  const OrderAsc = 0;
62  const OrderDesc = 1;
63 
65  const SortNone = 0;
67  const SortName = 1;
69  const SortDate = 2;
70 
72  const Options = (
73  "log_info",
74  "log_detail",
75  "log_debug",
76  "poll_interval",
77  "reopt",
78  "sleep",
79  "sort_order",
80  "sort_type",
81  "start_thread",
82  );
83 
85  const RequiredKeys = (
86  "sleep",
87  "start_thread",
88  );
89 
90 public:
91 
92  private :
94  string path;
95 
97  string mask;
98 
100  int poll_interval = 10;
101 
103  bool runflag = False;
104 
106  bool fatal = False;
107 
109  int pollcnt = 0;
110 
112  int sort_type = SortName;
113 
115  int sort_order = OrderAsc;
116 
119 
121  int tid;
122 
125 
127  int reopt;
128 
130  *softint minage;
131 
133  *code log_info;
134 
136  *code log_detail;
137 
139  *code log_debug;
140 
143 
145  *code sleep;
146 
147 public:
148 
150 
171  constructor(string n_path, string n_mask, *hash n_opts);
172 
173 
175  destructor();
176 
177 
179 
194  list getFiles(int sort = FilePoller::SortNone, int order = FilePoller::OrderAsc);
195 
196 
198 
201  int start();
202 
203 
205 
213  stop();
214 
215 
217 
221  stopNoWait();
222 
223 
225 
232  waitStop();
233 
234 
236 
239  startInline();
240 
241 
243  bool runOnce();
244 
245 
247 
248 private:
249  fileSleep(softint secs);
250 public:
251 
252 
254 
255 private:
256  run();
257 public:
258 
259 
261  fileEvent(list files);
262 
263 
265 
277  abstract singleFileEvent(hash fih);
278 
280 
283  static checkPath(string path, string type, bool write = False);
284 
286  int getPollCount();
287 
288 
290 
291 private:
292  logInfo(string fmt);
293 public:
294 
295 
297 
298 private:
299  logDetail(string fmt);
300 public:
301 
302 
304 
305 private:
306  logDebug(string fmt);
307 public:
308 
309  };
310 };
311 // END
main module namespace
Definition: FilePoller.qm.dox.h:53
*code sleep
optional sleep closure
Definition: FilePoller.qm.dox.h:145
string mask
file name mask
Definition: FilePoller.qm.dox.h:97
*code log_info
optional info log closure
Definition: FilePoller.qm.dox.h:133
const False
auto sort(auto arg)
list list(...)
int tid
polling tid
Definition: FilePoller.qm.dox.h:121
string type(auto arg)
*softint minage
minimum file age in seconds before the file will be included in the list returned ...
Definition: FilePoller.qm.dox.h:130
*code log_detail
optional detail log closure
Definition: FilePoller.qm.dox.h:136
*code log_debug
optional debug log closure
Definition: FilePoller.qm.dox.h:139
hash hash(object obj)
*code start_thread
optional start thread closure
Definition: FilePoller.qm.dox.h:142
string path
path to monitor
Definition: FilePoller.qm.dox.h:94
int reopt
regex options
Definition: FilePoller.qm.dox.h:127