libdballe  7.21
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
dballe::Msg Class Reference

Storage for related physical data. More...

#include <msg.h>

Inheritance diagram for dballe::Msg:
dballe::Message

Public Member Functions

 Msg ()
 Create a new dba_msg. More...
 
 Msg (const Msg &m)
 
Msgoperator= (const Msg &m)
 
std::unique_ptr< Messageclone () const override
 Return a copy of this message.
 
Datetime get_datetime () const override
 Get the reference Datetime for this message.
 
const wreport::Varget (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::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(), Trange());.
 
wreport::Varedit (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::Varfind_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::Varedit_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 Msgdowncast (const Message &o)
 Return a reference to o downcasted as a Msg. More...
 
static Msgdowncast (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 Msglua_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.
 

Detailed Description

Storage for related physical data.

Constructor & Destructor Documentation

§ Msg()

dballe::Msg::Msg ( )

Create a new dba_msg.

By default, type is MSG_GENERIC

Member Function Documentation

§ add_context()

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

§ diff()

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

Compute the differences between two Messages.

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

See also
wreport/notes.h).
Returns
The number of differences found

Implements dballe::Message.

§ downcast() [1/2]

static const Msg& dballe::Msg::downcast ( const Message o)
static

Return a reference to o downcasted as a Msg.

Throws an exception if o is not a Msg.

§ downcast() [2/2]

static Msg& dballe::Msg::downcast ( Message o)
static

Return a reference to o downcasted as a Msg.

Throws an exception if o is not a Msg.

§ edit()

wreport::Var* dballe::Msg::edit ( wreport::Varcode  code,
const Level lev,
const Trange tr 
)

Find a variable given its description.

Parameters
codeThe wreport::Varcode of the variable to query.
levThe Level to query
trThe Trange to query
Returns
The variable found, or NULL if it was not found.

§ edit_by_id()

wreport::Var* dballe::Msg::edit_by_id ( int  id)

Find a datum given its shortcut ID.

Parameters
idShortcut ID of the value to set.
Returns
The value found, or NULL if it was not found.

§ edit_context()

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.

§ find_by_id()

const wreport::Var* dballe::Msg::find_by_id ( int  id) const

Find a datum given its shortcut ID.

Parameters
idShortcut ID of the value to set.
Returns
The value found, or NULL if it was not found.

§ find_context()

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.

§ find_context_by_id()

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
idShortcut ID with the level information to use
Returns
The context found, or NULL if it was not found.

§ find_station_context()

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.

§ from_csv()

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

§ get()

const wreport::Var* dballe::Msg::get ( wreport::Varcode  code,
const Level lev,
const Trange tr 
) const
overridevirtual

Get a variable given its code, level and time range information.

Returns
A pointer to the variable, or nullptr if it was not found.

Implements dballe::Message.

§ lua_check()

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

§ obtain_context()

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

§ remove()

bool dballe::Msg::remove ( wreport::Varcode  code,
const Level lev,
const Trange tr 
)

Remove a variable given its description.

Parameters
codeThe wreport::Varcode of the variable to query.
levThe Level to query
trThe Trange to query
Returns
True if the variable was removed, false if it was not found.

§ remove_context()

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

§ set() [1/2]

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

§ set() [2/2]

void dballe::Msg::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.

Parameters
varThe Var with the value to set. This Msg will take ownership of memory management.
levThe Level of the value
trThe Trange of the value

§ set_by_id()

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

§ setc()

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

§ setd()

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

§ seti()

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

§ sounding_pack_levels()

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: