1 /***************************************************************************
2                           lockctrl.h  -  description
3                              -------------------
4     begin                : Mon Mar 10 2003
5     copyright            : (C) 2003 by Sheldon Lee Wen
6     email                : leewsb@hotmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef LOCKCTRL_H
19 #define LOCKCTRL_H
20 
21 #include <string>
22 /**Controls setting, and removing the lockfile, as well as checking whether or not a lineakd process is running.
23   *@author Sheldon Lee Wen
24   */
25 using namespace std;
26 
27 class lockCtrl
28 {
29 public:
30   lockCtrl (string process);
31   ~lockCtrl ();
32   /** Create the lock */
33   bool lock ();
34   /** Relock. Remove and replace the lock */
relock()35   bool relock ()
36   {
37     unlock ();
38     return (lock ());
39   }
40   /** Is the lock set? */
41   bool isLocked ();
42   /** Remove the lock */
43   void unlock ();
44 private:
45   static bool locked;
46   string lockfile;
47   string proc;
48   int locks;
49 };
50 
51 #endif
52