00001
00003
00021 #ifndef APPINST_H_
00022 #define APPINST_H_
00023
00024
00025 #include <string>
00026
00027
00028 #define APPLOCK_BASEDIR "/var/run"
00029
00030
00032
00035 class AppInstException
00036 {
00037 public:
00039
00042 AppInstException(int iErr) : m_iErr(iErr) {}
00043
00045
00048 inline int GetErrorNumber() const
00049 {
00050 return m_iErr;
00051 }
00052
00053 private:
00054 int m_iErr;
00055
00056 };
00057
00059
00064 class AppInstance
00065 {
00066 public:
00068
00075 AppInstance(const std::string& rName, const std::string& rBase = APPLOCK_BASEDIR);
00076
00078 ~AppInstance();
00079
00081
00089 bool Lock();
00090
00092
00097 void Unlock();
00098
00100
00107 bool Exists() const;
00108
00110
00116 bool SendSignal(int iSigNo) const;
00117
00118 protected:
00119 bool DoLock();
00120
00121 private:
00122 std::string m_path;
00123 bool m_fLocked;
00124 };
00125
00126 #endif