libwreport 3.38
tabledir.h
1#ifndef WREPORT_TABLEDIR_H
2#define WREPORT_TABLEDIR_H
3
4#include <wreport/tableinfo.h>
5#include <filesystem>
6#include <string>
7#include <vector>
8
9namespace wreport {
10struct Vartable;
11struct DTable;
12
13namespace tabledir {
14struct Index;
15
16struct Table
17{
18 std::string btable_id;
19 std::filesystem::path btable_pathname;
20 std::string dtable_id;
21 std::filesystem::path dtable_pathname;
22
23 Table(const std::filesystem::path& dirname, const std::string& filename);
24 virtual ~Table() {}
25
26 virtual void print_id(FILE* out) const;
27};
28
31{
32 BufrTableID id;
33
34 BufrTable(const BufrTableID& id, const std::string& dirname, const std::string& filename)
35 : Table(dirname, filename), id(id) {}
36
37 void print_id(FILE* out) const override;
38};
39
42{
43 CrexTableID id;
44
45 CrexTable(const CrexTableID& id, const std::string& dirname, const std::string& filename)
46 : Table(dirname, filename), id(id) {}
47
48 void print_id(FILE* out) const override;
49};
50
51
53struct Dir
54{
55 std::string pathname;
56 time_t mtime;
57 std::vector<Table*> tables;
58
59 Dir(const std::string& pathname);
60 Dir(const Dir&) = delete;
61 Dir(Dir&&) = default;
62 ~Dir();
63
64 Dir& operator=(const Dir&) = delete;
65
67 void refresh();
68};
69
71{
72protected:
73 std::vector<std::string> dirs;
74 Index* index;
75
76public:
77 Tabledirs();
78 Tabledirs(const Tabledirs&) = delete;
79 ~Tabledirs();
80
81 Tabledirs& operator=(const Tabledirs&) = delete;
82
88
90 void add_directory(const std::string& dir);
91
94
97
99 const tabledir::Table* find(const std::string& basename);
100
102 void print(FILE* out);
103
105 void explain_find_bufr(const BufrTableID& id, FILE* out);
106
108 void explain_find_crex(const CrexTableID& id, FILE* out);
109
111 static Tabledirs& get();
112};
113
114}
115}
116
117#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:71
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:31
Information about a version of a CREX table.
Definition: tabledir.h:42
Indexed version of a table directory.
Definition: tabledir.h:54
void refresh()
Reread the directory contents if it has changed.
Definition: tabledir.h:17