CARMA C++
TransferDB.h
Go to the documentation of this file.
1 
11 #ifndef CARMA_ARCHIVE_TRANSFERDB_H_
12 #define CARMA_ARCHIVE_TRANSFERDB_H_
13 
14 // C includes
15 #include <sys/types.h>
16 //#include <dirent.h>
17 #include <stdio.h>
18 //#include <zlib.h>
19 #include <errno.h>
20 
21 // Std C++ includes
22 #include <iostream>
23 #include <fstream>
24 #include <exception>
25 #include <vector>
26 #include <string>
27 
28 // Carma include
29 #include <carma/services/Table.h>
30 
31 // Carma tools includes
32 #include "log4cpp/Category.hh"
33 
34 namespace carma {
35 namespace archive {
36 
37 class TransferDB
38 {
39  public:
40 
41  typedef enum {
42  FILE_NAME = 0,
43  FILE_SIZE = 1,
44  CHECKSUM = 2,
45  TRANSF_DATE = 3,
46  DELETE_DATE = 4,
47  TIMESTAMP = 5
48  } ColumnNumber;
49 
53  TransferDB();
54 
55  TransferDB(std::string mutex, std::string dbFilename);
56 
60  ~TransferDB();
61 
65  carma::services::Table getTable();
66 
70  std::vector<std::string> getKeys();
71 
75  std::vector<std::string> getDeleteDates();
76 
80  std::vector<std::string> getTimestamps();
81 
85  std::string getChecksum();
86 
90  void update(int row, int col, std::string value);
91 
95  void add(std::string aRow);
96 
100  void removeRow(int row);
101 
105  void updateDBFile(std::vector<std::string>& dbRecords, bool append);
106 
111  void clearOldLock();
112 
113  private:
114 
118  int getLock();
119 
123  void releaseLock();
124 
128  std::vector<std::string> tokenize(std::string& line);
129 
133  std::string lock;
134 
138  carma::services::Table dbTable;
139 
143  std::string dbFile;
144 };
145 
146 }} // namespace carma::archive
147 
148 #endif /*CARMA_ARCHIVE_TRANSFERDB_H_*/
Common table functions.
Simple ASCII Table format, fully memory based.
Definition: Table.h:126