libwreport 3.34
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
8namespace wreport {
9struct Vartable;
10struct DTable;
11
12namespace tabledir {
13struct Index;
14
15struct 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
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
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
52struct 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
70{
71protected:
72 std::vector<std::string> dirs;
73 Index* index;
74
75public:
76 Tabledirs();
77 Tabledirs(const Tabledirs&) = delete;
78 ~Tabledirs();
79
80 Tabledirs& operator=(const Tabledirs&) = delete;
81
87
89 void add_directory(const std::string& dir);
90
93
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 BUFR tables.
Definition: tableinfo.h:14
Identifying information for one distinct instance of CREX tables.
Definition: tableinfo.h:44
Definition: tabledir.h:70
const tabledir::Table * find(const std::string &basename)
Find a BUFR or CREX table by file name.
void add_default_directories()
Add the default directories according to compile-time and environment variables.
void explain_find_bufr(const BufrTableID &id, FILE *out)
Print the step by step process by which a table is selected for id.
const tabledir::Table * find_bufr(const BufrTableID &id)
Find a BUFR table.
static Tabledirs & get()
Get the default tabledir instance.
void add_directory(const std::string &dir)
Add a table directory to this collection.
void print(FILE *out)
Print a list of all tables found.
void explain_find_crex(const CrexTableID &id, FILE *out)
Print the step by step process by which a table is selected for id.
const tabledir::Table * find_crex(const CrexTableID &id)
Find a CREX table.
String functions.
Definition: benchmark.h:13
Information about a version of a BUFR table.
Definition: tabledir.h:30
Information about a version of a CREX table.
Definition: tabledir.h:41
Indexed version of a table directory.
Definition: tabledir.h:53
void refresh()
Reread the directory contents if it has changed.
Definition: tabledir.h:16