INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
lockfile.h 00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 #ifndef GBXSERIALACFR_LOCKFILE_H 00011 #define GBXSERIALACFR_LOCKFILE_H 00012 00013 #include <unistd.h> 00014 #include <exception> 00015 #include <string> 00016 00017 namespace gbxserialacfr { 00018 namespace lockfile { 00019 00023 class LockFileException : public std::exception 00024 { 00025 std::string message_; 00026 public: 00027 LockFileException( const std::string &message ) 00028 : message_(message) {} 00029 ~LockFileException()throw(){} 00030 virtual const char* what() const throw() { return message_.c_str(); } 00031 }; 00032 00036 class LockedByOtherProcessException : public LockFileException 00037 { 00038 public: 00039 LockedByOtherProcessException( const std::string &message ) 00040 : LockFileException(message) {} 00041 ~LockedByOtherProcessException()throw(){} 00042 }; 00043 00057 class LockFile { 00058 public: 00059 00060 LockFile( const std::string &dev, 00061 int lockPid = getpid() ); 00062 ~LockFile(); 00063 00064 private: 00065 00066 const std::string dev_; 00067 const int lockPid_; 00068 00069 }; 00070 00071 } 00072 } 00073 #endif |