Apache Log4cxx  Version 1.5.0
filewatchdog.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HELPERS_FILEWATCHDOG_H
19 #define _LOG4CXX_HELPERS_FILEWATCHDOG_H
20 
21 #include <log4cxx/logstring.h>
22 #include <time.h>
23 #include <log4cxx/helpers/pool.h>
24 #include <log4cxx/file.h>
25 
26 namespace LOG4CXX_NS
27 {
28 namespace helpers
29 {
30 
35 class LOG4CXX_EXPORT FileWatchdog
36 {
37  public:
38  virtual ~FileWatchdog();
42  static long DEFAULT_DELAY /*= 60000 ms*/;
43 
44  protected:
45  FileWatchdog(const File& filename);
46  virtual void doOnChange() = 0;
48  const File& file();
49 
50  public:
54  void setDelay(long delay);
55 
59  void setFile(const File& filename);
60 
64  void start();
65 
69  void stop();
70 
74  bool is_active();
75 
79  static void stopAll();
80  private:
81 
82  FileWatchdog(const FileWatchdog&);
83  FileWatchdog& operator=(const FileWatchdog&);
84 
85  LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(FileWatchdogPrivate, m_priv)
86 };
87 } // namespace helpers
88 } // namespace log4cxx
89 
90 
91 #endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H
An abstract representation of file and directory path names.
Definition: file.h:41
Check every now and then that a certain file has not changed.
Definition: filewatchdog.h:36
void setDelay(long delay)
Use delay as the number of milliseconds to wait between each check for file changes.
bool is_active()
Is the task that periodically checks for a file change running?
void start()
Create an asynchronous task that periodically checks for a file change after first calling doOnChange...
void stop()
Stop the task that periodically checks for a file change.
FileWatchdog(const File &filename)
static void stopAll()
Stop all tasks that periodically check for a file change.
void setFile(const File &filename)
Change the watched file to filename.