UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DbLockTable.H
1 /* DbLockTable.H */
2 /* $Id: DbLockTable.H,v 1.4 2004/09/01 11:53:58 ibadm Exp $ */
3 #ifndef __DbLockTable_H
4 #define __DbLockTable_H
5 
6 #include <mix/Lock.H>
7 #include <mix/FileLock.H>
8 #include <ldb/DbTable.H>
9 #include <ldb/DbName.H>
10 #include <ldb/dblocks.h>
11 
12 
18 class DbLTName :
19  public DbName /* file name of lock's table is derived from dbname */
20 {
21 public:
22 
23  DbLTName (const dbNameStruct& dbns);
24  DbLTName (const char* szFileName);
25 
27  const char* exclock_fname () const;
28 
30  const char* shalock_fname () const;
31 
32 
35  const char* exclock_fpath (const char* project = NULL);
36 
39  const char* shalock_fpath (const char* project = NULL);
40 
41 protected:
42 
44  virtual void rebuild_fname ();
45 
46 private:
47 
49  char shared_fname[DB_FILE_NAME_LEN + sizeof(DB_LOCK_SHARED_FNAME_EXT) + 1];
50 
52  char *shared_fpath;
53 
55  char exclus_fname[DB_FILE_NAME_LEN + sizeof(DB_LOCK_EXCL_FNAME_EXT) + 1];
56 
58  char *exclus_fpath;
59 
60 };
61 
62 
68 class DbLockTable :
69  public DbLTName, /* name of the table objects */
70  public FileLock, /* lock lock's table exclusively */
71  public DbTable /* read it as a data base table */
72 {
73 public:
74 
77  DbLockTable (const char* project, const dbNameStruct& dbns);
78  DbLockTable (const char* project, const char* szDbFileName);
79 
81  virtual ~DbLockTable ();
82 
84  ErrCode add_lock (LockId& glid, DbAccess dbac);
85 
87  ErrCode delete_lock (LockId glid);
88 
90  DbIndex find_lock (LockId glid);
91 
94  DbIndex find_lock ();
95 
98  static const char* dbac2symb (DbAccess dbac);
99 
101  static DbAccess symb2dbac (const char* s);
102 
103 private:
104 
106  int sha_fd;
107 
109  void load_table ();
110 
112  void save_table ();
113 
114 };
115 
116 
117 #endif /* DbLockTable.H */
Definition: DbName.H:14
static DbAccess symb2dbac(const char *s)
Definition: dbnamedefs.h:67
#define DB_LOCK_EXCL_FNAME_EXT
Definition: dblocks.h:29
#define DB_LOCK_SHARED_FNAME_EXT
Definition: dblocks.h:32
const char * exclock_fpath(const char *project=NULL)
ErrCode delete_lock(LockId glid)
virtual void rebuild_fname()
virtual ~DbLockTable()
DbLockTable(const char *project, const dbNameStruct &dbns)
const char * shalock_fname() const
const char * exclock_fname() const
DbIndex find_lock()
Definition: DbTable.H:84
Definition: DbLockTable.H:18
const char * shalock_fpath(const char *project=NULL)
Definition: DbLockTable.H:68
Definition: FileLock.H:15
static const char * dbac2symb(DbAccess dbac)
ErrCode add_lock(LockId &glid, DbAccess dbac)