tabledir.h
#ifndef WREPORT_TABLEDIR_H
#define WREPORT_TABLEDIR_H
#include <wreport/tableinfo.h>
#include <string>
#include <vector>
namespace wreport {
struct Vartable;
struct DTable;
namespace tabledir {
struct Index;
struct Table
{
std::string btable_id;
std::string btable_pathname;
std::string dtable_id;
std::string dtable_pathname;
Table(const std::string& dirname, const std::string& filename);
virtual ~Table() {}
virtual void print_id(FILE* out) const;
};
struct BufrTable : Table
{
BufrTableID id;
BufrTable(const BufrTableID& id, const std::string& dirname, const std::string& filename)
: Table(dirname, filename), id(id) {}
void print_id(FILE* out) const override;
};
struct CrexTable : Table
{
CrexTableID id;
CrexTable(const CrexTableID& id, const std::string& dirname, const std::string& filename)
: Table(dirname, filename), id(id) {}
void print_id(FILE* out) const override;
};
struct Dir
{
std::string pathname;
time_t mtime;
std::vector<Table*> tables;
Dir(const std::string& pathname);
Dir(const Dir&) = delete;
Dir(Dir&&) = default;
~Dir();
Dir& operator=(const Dir&) = delete;
void refresh();
};
class Tabledirs
{
protected:
std::vector<std::string> dirs;
Index* index;
public:
Tabledirs();
Tabledirs(const Tabledirs&) = delete;
~Tabledirs();
Tabledirs& operator=(const Tabledirs&) = delete;
void add_default_directories();
void add_directory(const std::string& dir);
const tabledir::Table* find_bufr(const BufrTableID& id);
const tabledir::Table* find_crex(const CrexTableID& id);
const tabledir::Table* find(const std::string& basename);
void print(FILE* out);
void explain_find_bufr(const BufrTableID& id, FILE* out);
void explain_find_crex(const CrexTableID& id, FILE* out);
static Tabledirs& get();
};
}
}
#endif
wreport::BufrTableID
Identifying information for one distinct instance of BUFR tables.
Definition tableinfo.h:14
wreport::CrexTableID
Identifying information for one distinct instance of CREX tables.
Definition tableinfo.h:44
wreport::DTable
BUFR/CREX table D with Dxxyyy aggregate code expansions.
Definition dtable.h:14
wreport::Vartable
Holds a variable information table.
Definition vartable.h:30
wreport::tabledir::Tabledirs::find
const tabledir::Table * find(const std::string &basename)
Find a BUFR or CREX table by file name.
wreport::tabledir::Tabledirs::add_default_directories
void add_default_directories()
Add the default directories according to compile-time and environment variables.
wreport::tabledir::Tabledirs::explain_find_bufr
void explain_find_bufr(const BufrTableID &id, FILE *out)
Print the step by step process by which a table is selected for id.
wreport::tabledir::Tabledirs::find_bufr
const tabledir::Table * find_bufr(const BufrTableID &id)
Find a BUFR table.
wreport::tabledir::Tabledirs::get
static Tabledirs & get()
Get the default tabledir instance.
wreport::tabledir::Tabledirs::add_directory
void add_directory(const std::string &dir)
Add a table directory to this collection.
wreport::tabledir::Tabledirs::print
void print(FILE *out)
Print a list of all tables found.
wreport::tabledir::Tabledirs::explain_find_crex
void explain_find_crex(const CrexTableID &id, FILE *out)
Print the step by step process by which a table is selected for id.
wreport::tabledir::Tabledirs::find_crex
const tabledir::Table * find_crex(const CrexTableID &id)
Find a CREX table.
wreport
String functions.
Definition benchmark.h:13
wreport::tabledir::Dir::refresh
void refresh()
Reread the directory contents if it has changed.
wreport::tabledir::Table
Definition tabledir.h:16