version  0.0.1
Defines the C++ API for MsPASS
Public Member Functions | Public Attributes | Friends | List of all members
mspass::utility::AttributeProperties Class Reference

Defines properties of a database attribute and link to internal names. More...

#include <AttributeMap.h>

Public Member Functions

 AttributeProperties ()
 
 AttributeProperties (const std::string)
 Create using a string description. The standard construction of an associative array uses this constructor driven by a series of input lines. The input line that is parsed must contain these member attributes in the following order: More...
 
 AttributeProperties (const AttributeProperties &)
 Standard copy constructor.
 
AttributePropertiesoperator= (const AttributeProperties &)
 Standard assignment operator.
 
std::string fully_qualified_name () const
 Returns full name. More...
 

Public Attributes

std::string db_attribute_name
 
std::string db_table_name
 Database table name from which this attribute was loaded. Relational databases always share attribute names with multiple tables. This is a fundamental axiom in relational database theory. Because an attribute of the same name may or may not be related in different tables it is necessary to define the parent table to avoid ambiguity. Note that in MsPASS a common convention is that a db_attribute_name may contain the parent table implicity (e.g. wfdisc.sta) but code using this object should not assume this. User should assume the correct table name is stored here.
 
std::string internal_name
 
MDtype mdt
 
bool is_key
 Defines if parameter is a key in it's parent table. Keys in a relational database are special attributes and it is useful to tag a parameter as being a key or not a key. When true this attribute indicates a parameter is a key for db_table_name.
 

Friends

std::ostream & operator<< (std::ostream &ofs, const AttributeProperties &d)
 

Detailed Description

Defines properties of a database attribute and link to internal names.

This object is used to define the relationship between a parameter stored externally (originally conceived as a database attribute general enough for any externally imposed naming convention) with a particular name with some internal naming convention. This object defines the relationship for one internal parameter and it's external properties. Arrays of these objects or (as used in the AttributeMap object in MsPASS) associate arrays can be used to define relationships for a complete set of parameter names. Note this could have been called a struct since all the attributes are public.

Constructor & Destructor Documentation

◆ AttributeProperties() [1/2]

mspass::utility::AttributeProperties::AttributeProperties ( )

Default constructor. Creates a null object with MTtype set to invalid. This constructor exists to avoid automatic construction with no parameters, but it should not be used.

14 {
15  db_attribute_name="none";
16  db_table_name="";
17  internal_name="NULL";
18  mdt=MDtype::String;
19 }
std::string db_attribute_name
Definition: AttributeMap.h:27
std::string db_table_name
Database table name from which this attribute was loaded. Relational databases always share attribute...
Definition: AttributeMap.h:37
std::string internal_name
Definition: AttributeMap.h:39
MDtype mdt
Definition: AttributeMap.h:41

◆ AttributeProperties() [2/2]

mspass::utility::AttributeProperties::AttributeProperties ( const std::string  )

Create using a string description. The standard construction of an associative array uses this constructor driven by a series of input lines. The input line that is parsed must contain these member attributes in the following order:

  1. internal_name
  2. db_attribute_name
  3. db_table_name
  4. mdt

The mdt field must be one of "REAL", "real", "STRING", "string", "INT", "int", "BOOL", "BOOLEAN", "bool", or "boolean". Any other field with cause this constructor to throw an exception.

Exceptions
MetadataErroris thrown for parsing errors.

Member Function Documentation

◆ fully_qualified_name()

string mspass::utility::AttributeProperties::fully_qualified_name ( ) const

Returns full name.

Database attribute names can and often do occur in multiple tables. This method returns a full name that is used to uniquely define that attribute in a particular table. Although this could be generalized, for the present this is always returned in the form used by Antelope/datascope: that is the string is if the form table.attribute.

111 {
112  string result;
113  result=db_table_name + "." + db_attribute_name;
114  return(result);
115 }

Member Data Documentation

◆ db_attribute_name

std::string mspass::utility::AttributeProperties::db_attribute_name

Name for this parameter as the attribute name in some database table.

◆ internal_name

std::string mspass::utility::AttributeProperties::internal_name

Internal name used to reference this parameter.

◆ mdt

MDtype mspass::utility::AttributeProperties::mdt

Type of this parameter.


The documentation for this class was generated from the following files: