libwreport  3.23
tabledir.h
1 #ifndef WREPORT_TABLEDIR_H
2 #define WREPORT_TABLEDIR_H
3 
4 #include <wreport/tableinfo.h>
5 #include <string>
6 #include <vector>
7 
8 namespace wreport {
9 struct Vartable;
10 struct DTable;
11 
12 namespace tabledir {
13 struct Index;
14 
15 struct Table
16 {
17  std::string btable_id;
18  std::string btable_pathname;
19  std::string dtable_id;
20  std::string dtable_pathname;
21 
22  Table(const std::string& dirname, const std::string& filename);
23  virtual ~Table() {}
24 
25  virtual void print_id(FILE* out) const;
26 };
27 
29 struct BufrTable : Table
30 {
31  BufrTableID id;
32 
33  BufrTable(const BufrTableID& id, const std::string& dirname, const std::string& filename)
34  : Table(dirname, filename), id(id) {}
35 
36  void print_id(FILE* out) const override;
37 };
38 
40 struct CrexTable : Table
41 {
42  CrexTableID id;
43 
44  CrexTable(const CrexTableID& id, const std::string& dirname, const std::string& filename)
45  : Table(dirname, filename), id(id) {}
46 
47  void print_id(FILE* out) const override;
48 };
49 
50 
52 struct Dir
53 {
54  std::string pathname;
55  time_t mtime;
56  std::vector<Table*> tables;
57 
58  Dir(const std::string& pathname);
59  Dir(const Dir&) = delete;
60  Dir(Dir&&) = default;
61  ~Dir();
62 
63  Dir& operator=(const Dir&) = delete;
64 
66  void refresh();
67 };
68 
69 class Tabledirs
70 {
71 protected:
72  std::vector<std::string> dirs;
73  Index* index;
74 
75 public:
76  Tabledirs();
77  Tabledirs(const Tabledirs&) = delete;
78  ~Tabledirs();
79 
80  Tabledirs& operator=(const Tabledirs&) = delete;
81 
86  void add_default_directories();
87 
89  void add_directory(const std::string& dir);
90 
92  const tabledir::Table* find_bufr(const BufrTableID& id);
93 
95  const tabledir::Table* find_crex(const CrexTableID& id);
96 
98  const tabledir::Table* find(const std::string& basename);
99 
101  void print(FILE* out);
102 
104  void explain_find_bufr(const BufrTableID& id, FILE* out);
105 
107  void explain_find_crex(const CrexTableID& id, FILE* out);
108 
110  static Tabledirs& get();
111 };
112 
113 }
114 }
115 
116 #endif
Identifying information for one distinct instance of CREX tables.
Definition: tableinfo.h:43
Indexed version of a table directory.
Definition: tabledir.h:52
Definition: tabledir.h:69
Information about a version of a CREX table.
Definition: tabledir.h:40
String functions.
Definition: benchmark.h:13
Information about a version of a BUFR table.
Definition: tabledir.h:29
Identifying information for one distinct instance of BUFR tables.
Definition: tableinfo.h:14
Definition: tabledir.h:15