libdballe  6.8
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions
dballe::Msg Class Reference

Storage for related physical data. More...

#include <msg.h>

Public Member Functions

 Msg ()
 Create a new dba_msg. More...
 
 Msg (const Msg &m)
 
Msgoperator= (const Msg &m)
 
void clear ()
 Remove all information from Msg.
 
void add_context (std::auto_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::Contextfind_context (const Level &lev, const Trange &tr) const
 Find a msg::Context given its description. More...
 
const msg::Contextfind_station_context () const
 Find the station info context. More...
 
msg::Contextedit_context (const Level &lev, const Trange &tr)
 Find a msg::Context given its description. More...
 
msg::Contextobtain_context (const Level &lev, const Trange &tr)
 Find a msg::Context given its description, creating it if it does not exist. More...
 
msg::Contextobtain_station_context ()
 Shortcut to obtain_context(Level::ana(), Trange::ana());.
 
const wreport::Var * find (wreport::Varcode code, const Level &lev, const Trange &tr) const
 Find a variable given its description. More...
 
wreport::Var * edit (wreport::Varcode code, const Level &lev, const Trange &tr)
 Find 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::Contextfind_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::auto_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 set_date (const char *date)
 Set the date from a string in the format "YYYY-MM-DD HH:MM:SS".
 
void sounding_pack_levels (Msg &dst) const
 Copy to dest all the variable in this message that match filter TODO: to be implemented. More...
 
void parse_date (int *values) const
 Parse the date set in the Msg. More...
 
bool from_csv (CSVReader &in)
 Read data from a CSV input. More...
 
void to_csv (std::ostream &out) const
 Output in CSV format.
 
void print (FILE *out) const
 Dump all the contents of the message to the given stream. More...
 
unsigned diff (const Msg &msg) const
 Compute the differences between two Msg. More...
 
void lua_push (struct lua_State *L)
 Push the variable as an object in the lua stack.
 

Static Public Member Functions

static void csv_header (std::ostream &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 Msglua_check (struct lua_State *L, int idx)
 Check that the element at idx is a dba_msg. More...
 

Data Fields

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.
 

Detailed Description

Storage for related physical data.

Constructor & Destructor Documentation

dballe::Msg::Msg ( )

Create a new dba_msg.

By default, type is MSG_GENERIC

Member Function Documentation

void dballe::Msg::add_context ( std::auto_ptr< msg::Context ctx)

Add a missing context, taking care of its memory management.

Note: if the context already exists, an exception is thrown

unsigned dballe::Msg::diff ( const Msg msg) const

Compute the differences between two Msg.

Details of the differences found will be formatted using the notes system (

See also
notes.h).
Parameters
msgMessage to compare this one to
Returns
The number of differences found
wreport::Var* dballe::Msg::edit ( wreport::Varcode  code,
const Level lev,
const Trange tr 
)

Find a variable given its description.

Parameters
codeThe ::dba_varcode of the variable to query. See vartable.h
levThe Level to query
trThe Trange to query
Returns
The variable found, or NULL if it was not found.
wreport::Var* dballe::Msg::edit_by_id ( int  id)

Find a datum given its shortcut ID.

Parameters
msgThe message to query
idShortcut ID of the value to set (see vars.h)
Returns
The value found, or NULL if it was not found.
msg::Context* dballe::Msg::edit_context ( const Level lev,
const Trange tr 
)

Find a msg::Context given its description.

Parameters
levThe Level to query
trThe Trange to query
Returns
The context found, or NULL if it was not found.
const wreport::Var* dballe::Msg::find ( wreport::Varcode  code,
const Level lev,
const Trange tr 
) const

Find a variable given its description.

Parameters
codeThe ::dba_varcode of the variable to query. See vartable.h
levThe Level to query
trThe Trange to query
Returns
The variable found, or NULL if it was not found.
const wreport::Var* dballe::Msg::find_by_id ( int  id) const

Find a datum given its shortcut ID.

Parameters
msgThe message to query
idShortcut ID of the value to set (see vars.h)
Returns
The value found, or NULL if it was not found.
const msg::Context* dballe::Msg::find_context ( const Level lev,
const Trange tr 
) const

Find a msg::Context given its description.

Parameters
levThe Level to query
trThe Trange to query
Returns
The context found, or NULL if it was not found.
const msg::Context* dballe::Msg::find_context_by_id ( int  id) const

Find a contexts given level and timerange found in a shortcut ID.

Parameters
msgThe message to query
idShortcut ID with the level information to use
Returns
The context found, or NULL if it was not found.
const msg::Context* dballe::Msg::find_station_context ( ) const

Find the station info context.

Returns
The context found, or NULL if it was not found.
bool dballe::Msg::from_csv ( CSVReader in)

Read data from a CSV input.

Reading stops when one of Longitude, Latitude, Report or Date changes.

Returns
true if some CSV data has been found, false on EOF
static Msg* dballe::Msg::lua_check ( struct lua_State *  L,
int  idx 
)
static

Check that the element at idx is a dba_msg.

Returns
the dba_msg element, or NULL if the check failed
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.

Parameters
levThe Level to query
trThe Trange to query
Returns
The context found
void dballe::Msg::parse_date ( int *  values) const

Parse the date set in the Msg.

This function will examine the values year, month, day, hour, min and sec, and will compute the lower bound of the datetime they represent.

Return values
valuesAn array of 6 integers that will be filled with the minimum year, month, day, hour, minute and seconds.
void dballe::Msg::print ( FILE *  out) const

Dump all the contents of the message to the given stream.

Parameters
outThe stream to dump the contents of the dba_msg to.
bool dballe::Msg::remove_context ( const Level lev,
const Trange tr 
)

Remove a context from the message.

Returns
true if the context was removed, false if it did not exist
void dballe::Msg::set ( const wreport::Var &  var,
wreport::Varcode  code,
const Level lev,
const Trange tr 
)

Add or replace a value.

Parameters
varThe Var with the value to set
codeThe dba_varcode of the destination value. If it is different than the varcode of var, a conversion will be attempted.
levThe Level of the value
trThe Trange of the value
void dballe::Msg::set ( std::auto_ptr< wreport::Var >  var,
const Level lev,
const Trange tr 
)

Add or replace a value, taking ownership of the source variable without copying it.

Parameters
msgThe Var with the value to set. This Msg will take ownership of memory management.
levThe Level of the value
trThe Trange of the value
void dballe::Msg::set_by_id ( const wreport::Var &  var,
int  shortcut 
)

Add or replace a value.

Parameters
varThe Var with the value to set
shortcutShortcut 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.

Parameters
codeThe dba_varcode of the destination value. See vartable.h
valThe string value of the data
confThe 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.
levThe Level of the value
trThe 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.

Parameters
codeThe dba_varcode of the destination value. See vartable.h
valThe double value of the data
confThe 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.
levThe Level of the value
trThe 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.

Parameters
codeThe dba_varcode of the destination value.. See vartable.h
valThe integer value of the data
confThe 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.
levThe Level of the value
trThe 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.


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