UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
locker.hpp
1 /* locker.hpp */
2 /* $Id$ */
3 #ifndef __locker_hpp
4 #define __locker_hpp
5 
6 #include <ctime>
7 #include <string>
8 #include <hds_db/base/defines.hpp>
9 
11 namespace hds
12 {
14  namespace db
15  {
17  enum LockType
18  {
19  LT_READ = 0,
21  };
22 
25  {
29  {/* nothing to do. */}
30 
32  LockDescription(const std::string &i_name,
33  const LockType &i_type,
34  const std::string &i_project,
35  const std::string &i_comment):
36  name(i_name), type(i_type), project(i_project), comment(i_comment)
37  {/* nothing to do. */}
38 
39  std::string name;
41  std::string project;
42  std::string comment;
43  time_t timestamp;
44  };
45 
47  typedef std::vector<LockDescription> LockDescriptionVec;
48 
50  class Locker
51  {
52  public:
53 
55  Locker();
56 
58  virtual ~Locker();
59 
68  virtual DbIndex lock(const LockDescription &ld) = 0;
69 
74  virtual void release(const DbIndex &id) = 0;
75 
81  virtual size_t releaseAll() = 0;
82 
83 
89  virtual void list(LockDescriptionVec &locks) = 0;
90 
91 
93  virtual ErrCode lastError() const = 0;
94  };
95  }; // db
96 }; // hds
97 
98 #endif /* locker.hpp */
Definition: locker.hpp:20
virtual ~Locker()
uint64_t DbIndex
Definition: defines.hpp:26
LockType type
Definition: locker.hpp:40
Definition: locker.hpp:50
std::string name
Definition: locker.hpp:39
LockDescription()
Definition: locker.hpp:27
ErrCode
Definition: defines.hpp:46
virtual ErrCode lastError() const =0
LockDescription(const std::string &i_name, const LockType &i_type, const std::string &i_project, const std::string &i_comment)
Definition: locker.hpp:32
Definition: locker.hpp:19
std::string comment
Definition: locker.hpp:42
virtual DbIndex lock(const LockDescription &ld)=0
virtual void release(const DbIndex &id)=0
time_t timestamp
Definition: locker.hpp:43
LockType
Definition: locker.hpp:17
virtual void list(LockDescriptionVec &locks)=0
std::vector< LockDescription > LockDescriptionVec
Definition: locker.hpp:47
std::string project
Definition: locker.hpp:41
Definition: locker.hpp:24
virtual size_t releaseAll()=0