version  0.0.1
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
MetadataDefinitions.h
1#ifndef _METADATADEFINITIONS_H_
2#define _METADATADEFINITIONS_H_
3#include <string>
4#include <map>
5#include <tuple>
6#include <list>
7#include "mspass/utility/Metadata.h"
8namespace mspass {
9namespace utility {
10using mspass::utility::MDtype;
11enum class MDDefFormat { PF, YAML };
12
31public:
41 MetadataDefinitions(const std::string mdname);
50 MetadataDefinitions(const std::string mdname,
51 const mspass::utility::MDDefFormat form);
55 bool is_defined(const std::string key) const noexcept;
63 std::string concept(const std::string key) const;
70 mspass::utility::MDtype type(const std::string key) const;
71 std::list<std::string> keys() const;
82 void add(const std::string key, const std::string concept_, const MDtype mdt);
91 bool has_alias(const std::string key) const;
99 bool is_alias(const std::string key) const;
100 std::list<std::string> aliases(const std::string key) const;
113 std::pair<std::string, mspass::utility::MDtype>
114 unique_name(const std::string aliasname) const;
120 void add_alias(const std::string key, const std::string aliasname);
128 bool writeable(const std::string key) const;
136 bool readonly(const std::string key) const;
148 void set_readonly(const std::string key);
160 void set_writeable(const std::string key);
168 bool is_normalized(const std::string key) const;
198 std::string unique_id_key(const std::string key) const;
214 std::string collection(const std::string key) const;
228 std::pair<std::string, std::string>
229 normalize_data(const std::string key) const;
245 std::list<std::string> apply_aliases(mspass::utility::Metadata &d,
246 const std::list<std::string> aliaslist);
283
284private:
285 std::map<std::string, MDtype> tmap;
286 std::map<std::string, std::string> cmap;
287 std::multimap<std::string, std::string> aliasmap;
288 std::map<std::string, std::string> alias_xref;
289 std::set<std::string> roset;
290 /* This map is used to handle normalized data in any database. For the
291 initial design the data could be a pair, but I make it a tuple because I
292 can conveive extensions that would require additional information to provides
293 a unique index definition. e.g. the antelope indexing of
294 sta,chan,time:endtime.
295 */
296 std::map<std::string, std::tuple<std::string, std::string>> unique_id_data;
297 void pfreader(const std::string pfname);
298 void yaml_reader(const std::string fname);
299};
300} // namespace utility
301} // namespace mspass
302#endif
Define properties of Metadata known to mspass.
Definition MetadataDefinitions.h:30
MetadataDefinitions(const std::string mdname, const mspass::utility::MDDefFormat form)
Construct from a file with variable formats.
void add_alias(const std::string key, const std::string aliasname)
Definition MetadataDefinitions.cc:152
bool has_alias(const std::string key) const
Methods to handle aliases.
Definition MetadataDefinitions.cc:127
std::list< std::string > apply_aliases(mspass::utility::Metadata &d, const std::list< std::string > aliaslist)
Apply a set of aliases to data.
Definition MetadataDefinitions.cc:478
MetadataDefinitions & operator=(const MetadataDefinitions &other)
Definition MetadataDefinitions.cc:200
bool writeable(const std::string key) const
Definition MetadataDefinitions.cc:257
void set_readonly(const std::string key)
Lock a parameter to assure it will not be saved.
Definition MetadataDefinitions.cc:292
void clear_aliases(mspass::utility::Metadata &d)
Restore any aliases to unique names.
Definition MetadataDefinitions.cc:498
void add(const std::string key, const std::string concept_, const MDtype mdt)
Definition MetadataDefinitions.cc:122
MetadataDefinitions()
Definition MetadataDefinitions.cc:44
bool is_alias(const std::string key) const
Ask if a key is a registered alias.
Definition MetadataDefinitions.cc:158
MetadataDefinitions & operator+=(const MetadataDefinitions &other)
Accumulate additional definitions.
Definition MetadataDefinitions.cc:212
std::pair< std::string, mspass::utility::MDtype > unique_name(const std::string aliasname) const
Definition MetadataDefinitions.cc:168
std::string unique_id_key(const std::string key) const
Returns a unique identifier for a normalized attribute.
Definition MetadataDefinitions.cc:314
mspass::utility::MDtype type(const std::string key) const
Definition MetadataDefinitions.cc:108
void set_writeable(const std::string key)
Force a key:value pair to be writeable.
Definition MetadataDefinitions.cc:298
bool readonly(const std::string key) const
Definition MetadataDefinitions.cc:289
std::pair< std::string, std::string > normalize_data(const std::string key) const
Special method for efficiency.
Definition MetadataDefinitions.cc:334
std::string collection(const std::string key) const
Definition MetadataDefinitions.cc:324
bool is_defined(const std::string key) const noexcept
Definition MetadataDefinitions.cc:78
bool is_normalized(const std::string key) const
Test if a key:value pair is set as normalized.
Definition MetadataDefinitions.cc:306
Definition Metadata.h:71