libdballe
7.19
|
Storage for related physical data. More...
#include <msg.h>
Public Member Functions | |
Msg () | |
Create a new dba_msg. More... | |
Msg (const Msg &m) | |
Msg & | operator= (const Msg &m) |
std::unique_ptr< Message > | clone () const override |
Return a copy of this message. | |
Datetime | get_datetime () const override |
Get the reference Datetime for this message. | |
const wreport::Var * | get (wreport::Varcode code, const Level &lev, const Trange &tr) const override |
Get a variable given its code, level and time range information. More... | |
void | print (FILE *out) const override |
Print all the contents of this message to an output stream. | |
unsigned | diff (const Message &msg) const override |
Compute the differences between two Messages. More... | |
void | set_rep_memo (const std::string &r) |
void | set_coords (const Coords &c) |
void | set_ident (const Ident &i) |
void | set_datetime (const Datetime &dt) |
void | clear () |
Remove all information from Msg. | |
void | add_context (std::unique_ptr< msg::Context > &&ctx) |
Add a missing context, taking care of its memory management. More... | |
bool | remove_context (const Level &lev, const Trange &tr) |
Remove a context from the message. More... | |
const msg::Context * | find_context (const Level &lev, const Trange &tr) const |
Find a msg::Context given its description. More... | |
const msg::Context * | find_station_context () const |
Find the station info context. More... | |
msg::Context * | edit_context (const Level &lev, const Trange &tr) |
Find a msg::Context given its description. More... | |
msg::Context & | obtain_context (const Level &lev, const Trange &tr) |
Find a msg::Context given its description, creating it if it does not exist. More... | |
msg::Context & | obtain_station_context () |
Shortcut to obtain_context(Level(), Trange());. | |
wreport::Var * | edit (wreport::Varcode code, const Level &lev, const Trange &tr) |
Find a variable given its description. More... | |
bool | remove (wreport::Varcode code, const Level &lev, const Trange &tr) |
Remove a variable given its description. More... | |
const wreport::Var * | find_by_id (int id) const |
Find a datum given its shortcut ID. More... | |
const msg::Context * | find_context_by_id (int id) const |
Find a contexts given level and timerange found in a shortcut ID. More... | |
wreport::Var * | edit_by_id (int id) |
Find a datum given its shortcut ID. More... | |
void | set (const wreport::Var &var, wreport::Varcode code, const Level &lev, const Trange &tr) |
Add or replace a value. More... | |
void | set_by_id (const wreport::Var &var, int shortcut) |
Add or replace a value. More... | |
void | set (std::unique_ptr< wreport::Var > &&var, const Level &lev, const Trange &tr) |
Add or replace a value, taking ownership of the source variable without copying it. More... | |
void | seti (wreport::Varcode code, int val, int conf, const Level &lev, const Trange &tr) |
Add or replace an integer value in the dba_msg. More... | |
void | setd (wreport::Varcode code, double val, int conf, const Level &lev, const Trange &tr) |
Add or replace a double value in the dba_msg. More... | |
void | setc (wreport::Varcode code, const char *val, int conf, const Level &lev, const Trange &tr) |
Add or replace a string value in the dba_msg. More... | |
void | sounding_pack_levels (Msg &dst) const |
Copy to dest all the variable in this message that match filter TODO: to be implemented. More... | |
bool | from_csv (CSVReader &in) |
Read data from a CSV input. More... | |
void | to_csv (CSVWriter &out) const |
Output in CSV format. | |
void | lua_push (struct lua_State *L) |
Push the variable as an object in the lua stack. | |
Static Public Member Functions | |
static const Msg & | downcast (const Message &o) |
Return a reference to o downcasted as a Msg. More... | |
static Msg & | downcast (Message &o) |
Return a reference to o downcasted as a Msg. More... | |
static void | csv_header (CSVWriter &out) |
Output the CSV header. | |
static MsgType | type_from_repmemo (const char *repmemo) |
Get the message source type corresponding to the given report code. | |
static const char * | repmemo_from_type (MsgType type) |
Get the report code corresponding to the given message source type. | |
static Msg * | lua_check (struct lua_State *L, int idx) |
Check that the element at idx is a dba_msg. More... | |
Public Attributes | |
MsgType | type |
Source of the data. | |
std::vector< msg::Context * > | data |
Context in the message. | |
Protected Member Functions | |
int | find_index (const Level &lev, const Trange &tr) const |
Return the index of the given context, or -1 if it was not found. | |
Protected Attributes | |
std::string | m_rep_memo |
Sensor network of origin of the Msg contents. | |
Coords | m_coords |
Reference coordinates for the Msg contents. | |
Ident | m_ident |
Identifier of the contents originator. | |
Datetime | m_datetime |
Reference time for the Msg contents. | |
Storage for related physical data.
dballe::Msg::Msg | ( | ) |
Create a new dba_msg.
By default, type is MSG_GENERIC
void dballe::Msg::add_context | ( | std::unique_ptr< msg::Context > && | ctx | ) |
Add a missing context, taking care of its memory management.
Note: if the context already exists, an exception is thrown
|
overridevirtual |
Compute the differences between two Messages.
Details of the differences found will be formatted using the wreport notes system (
Implements dballe::Message.
wreport::Var* dballe::Msg::edit | ( | wreport::Varcode | code, |
const Level & | lev, | ||
const Trange & | tr | ||
) |
wreport::Var* dballe::Msg::edit_by_id | ( | int | id | ) |
Find a datum given its shortcut ID.
id | Shortcut ID of the value to set. |
msg::Context* dballe::Msg::edit_context | ( | const Level & | lev, |
const Trange & | tr | ||
) |
Find a msg::Context given its description.
const wreport::Var* dballe::Msg::find_by_id | ( | int | id | ) | const |
Find a datum given its shortcut ID.
id | Shortcut ID of the value to set. |
const msg::Context* dballe::Msg::find_context | ( | const Level & | lev, |
const Trange & | tr | ||
) | const |
Find a msg::Context given its description.
const msg::Context* dballe::Msg::find_context_by_id | ( | int | id | ) | const |
Find a contexts given level and timerange found in a shortcut ID.
id | Shortcut ID with the level information to use |
const msg::Context* dballe::Msg::find_station_context | ( | ) | const |
Find the station info context.
bool dballe::Msg::from_csv | ( | CSVReader & | in | ) |
Read data from a CSV input.
Reading stops when one of Longitude, Latitude, Report or Date changes.
|
overridevirtual |
Get a variable given its code, level and time range information.
Implements dballe::Message.
|
static |
Check that the element at idx is a dba_msg.
msg::Context& dballe::Msg::obtain_context | ( | const Level & | lev, |
const Trange & | tr | ||
) |
Find a msg::Context given its description, creating it if it does not exist.
bool dballe::Msg::remove | ( | wreport::Varcode | code, |
const Level & | lev, | ||
const Trange & | tr | ||
) |
Remove a context from the message.
void dballe::Msg::set | ( | const wreport::Var & | var, |
wreport::Varcode | code, | ||
const Level & | lev, | ||
const Trange & | tr | ||
) |
void dballe::Msg::set | ( | std::unique_ptr< wreport::Var > && | var, |
const Level & | lev, | ||
const Trange & | tr | ||
) |
void dballe::Msg::set_by_id | ( | const wreport::Var & | var, |
int | shortcut | ||
) |
Add or replace a value.
var | The Var with the value to set |
shortcut | Shortcut ID of the value to set |
void dballe::Msg::setc | ( | wreport::Varcode | code, |
const char * | val, | ||
int | conf, | ||
const Level & | lev, | ||
const Trange & | tr | ||
) |
Add or replace a string value in the dba_msg.
code | The dba_varcode of the destination value. See vartable.h |
val | The string value of the data |
conf | The confidence interval of the data, as the value of a B33007 WMO B (per cent confidence) table entry, that is, a number between 0 and 100 inclusive. -1 means no confidence interval attribute. |
lev | The Level of the value |
tr | The Trange of the value |
void dballe::Msg::setd | ( | wreport::Varcode | code, |
double | val, | ||
int | conf, | ||
const Level & | lev, | ||
const Trange & | tr | ||
) |
Add or replace a double value in the dba_msg.
code | The dba_varcode of the destination value. See vartable.h |
val | The double value of the data |
conf | The confidence interval of the data, as the value of a B33007 WMO B (per cent confidence) table entry, that is, a number between 0 and 100 inclusive. -1 means no confidence interval attribute. |
lev | The Level of the value |
tr | The Trange of the value |
void dballe::Msg::seti | ( | wreport::Varcode | code, |
int | val, | ||
int | conf, | ||
const Level & | lev, | ||
const Trange & | tr | ||
) |
Add or replace an integer value in the dba_msg.
code | The dba_varcode of the destination value.. See vartable.h |
val | The integer value of the data |
conf | The confidence interval of the data, as the value of a B33007 WMO B (per cent confidence) table entry, that is, a number between 0 and 100 inclusive. -1 means no confidence interval attribute. |
lev | The Level of the value |
tr | The Trange of the value |
void dballe::Msg::sounding_pack_levels | ( | Msg & | dst | ) | const |
Copy to dest all the variable in this message that match filter TODO: to be implemented.
Copy a Msg, removing the sounding significance from the level descriptions and packing together the data at the same pressure level.
This is used to postprocess data after decoding, where the l2 field of the level description is temporarily used to store the vertical sounding significance, to simplify decoding.