libdballe 9.6
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
dballe::impl::Message Class Reference

Storage for related physical data. More...

#include <msg.h>

Inheritance diagram for dballe::impl::Message:
dballe::Message

Public Member Functions

 Message (const Message &)=default
 
 Message (Message &&)=default
 
Messageoperator= (const Message &m)=default
 
Messageoperator= (Message &&m)=default
 
std::shared_ptr< dballe::Messageclone () const override
 Return a copy of this message.
 
Datetime get_datetime () const override
 Get the reference Datetime for this message.
 
Coords get_coords () const override
 Get the reference coordinates for this message.
 
Ident get_ident () const override
 Get the station identifier for this message.
 
std::string get_report () const override
 Get the report for this message.
 
MessageType get_type () const override
 Return the type of the data in the message.
 
bool foreach_var (std::function< bool(const Level &, const Trange &, const wreport::Var &)>) const override
 Iterate the contents of the message.
 
void print (FILE *out) const override
 Print all the contents of this message to an output stream.
 
unsigned diff (const dballe::Message &msg) const override
 Compute the differences between two Messages.
 
void clear ()
 Reset the messages as if it was just created.
 
const wreport::Varget (const Shortcut &shortcut) const
 Find a datum given its shortcut.
 
void set (const Shortcut &shortcut, const wreport::Var &var)
 Add or replace a value.
 
void set_datetime (const Datetime &dt)
 Shortcut to set year...second variables in a single call.
 
bool remove_context (const Level &lev, const Trange &tr)
 Remove a context from the message.
 
const msg::Contextfind_context (const Level &lev, const Trange &tr) const
 Find a msg::Context given its description.
 
const Valuesfind_station_context () const
 Find the station info context.
 
msg::Contextedit_context (const Level &lev, const Trange &tr)
 Find a msg::Context given its description.
 
msg::Contextobtain_context (const Level &lev, const Trange &tr)
 Find a msg::Context given its description, creating it if it does not exist.
 
wreport::Varedit (wreport::Varcode code, const Level &lev, const Trange &tr)
 Find a variable given its description.
 
void sounding_pack_levels ()
 Remove the sounding significance from the level descriptions and pack together the data at the same pressure level.
 
bool from_csv (CSVReader &in)
 Read data from a CSV input.
 
void to_csv (CSVWriter &out) const
 Output in CSV format.
 
std::shared_ptr< dballe::CursorStationquery_stations (const Query &query) const override
 Return a Cursor to access the station information in the message.
 
std::shared_ptr< dballe::CursorStationDataquery_station_data (const Query &query) const override
 Query the station variables in the message.
 
std::shared_ptr< dballe::CursorDataquery_data (const Query &query) const override
 Query the variables in the message.
 
std::shared_ptr< dballe::CursorDataquery_station_and_data (const Query &query) const
 
- Public Member Functions inherited from dballe::Message
virtual MessageType get_type () const =0
 Return the type of the data in the message.
 
virtual Datetime get_datetime () const =0
 Get the reference Datetime for this message.
 
virtual Coords get_coords () const =0
 Get the reference coordinates for this message.
 
virtual Ident get_ident () const =0
 Get the station identifier for this message.
 
virtual std::string get_report () const =0
 Get the report for this message.
 
virtual std::shared_ptr< Messageclone () const =0
 Return a copy of this message.
 
const wreport::Varget (const Level &lev, const Trange &tr, wreport::Varcode code) const
 Get a variable given its code, level and time range information.
 
const wreport::Varget (const char *shortcut) const
 Get a variable given its shortcut name.
 
const wreport::Varget (const std::string &shortcut) const
 Get a variable given its shortcut name.
 
void set (const Level &lev, const Trange &tr, wreport::Varcode code, const wreport::Var &var)
 Add or replace a value.
 
void set (const Level &lev, const Trange &tr, const wreport::Var &var)
 Add or replace a value.
 
void set (const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var)
 Add or replace a value, taking ownership of the source variable without copying it.
 
void set (const char *shortcut, std::unique_ptr< wreport::Var > var)
 Add or replace a value, taking ownership of the source variable without copying it.
 
void set (const char *shortcut, const wreport::Var &var)
 Add or replace a value.
 
virtual bool foreach_var (std::function< bool(const Level &, const Trange &, const wreport::Var &)>) const =0
 Iterate the contents of the message.
 
virtual std::shared_ptr< CursorStationquery_stations (const Query &query) const =0
 Return a Cursor to access the station information in the message.
 
virtual std::shared_ptr< CursorStationDataquery_station_data (const Query &query) const =0
 Query the station variables in the message.
 
virtual std::shared_ptr< CursorDataquery_data (const Query &query) const =0
 Query the variables in the message.
 
virtual void print (FILE *out) const =0
 Print all the contents of this message to an output stream.
 
virtual unsigned diff (const Message &msg) const =0
 Compute the differences between two Messages.
 

Static Public Member Functions

static std::shared_ptr< Messagecreate ()
 
static const Messagedowncast (const dballe::Message &o)
 Return a reference to o downcasted as an impl::Message.
 
static Messagedowncast (dballe::Message &o)
 Return a reference to o downcasted as an impl::Message.
 
static std::shared_ptr< Messagedowncast (std::shared_ptr< dballe::Message > o)
 Returns a pointer to o downcasted as an impl::Message.
 
static void csv_header (CSVWriter &out)
 Output the CSV header.
 
static MessageType type_from_repmemo (const char *repmemo)
 Get the message source type corresponding to the given report code.
 
static const char * repmemo_from_type (MessageType type)
 Get the report code corresponding to the given message source type.
 
- Static Public Member Functions inherited from dballe::Message
static std::shared_ptr< Messagecreate (MessageType type)
 Create a new empty message.
 

Public Attributes

MessageType type = MessageType::GENERIC
 Source of the data.
 
Values station_data
 
msg::Contexts data
 

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.
 
const wreport::Varget_impl (const Level &lev, const Trange &tr, wreport::Varcode code) const override
 Implementation of get(const Level&, const Trange&, wreport::Varcode)
 
void set_impl (const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var) override
 Implementation of set(const Level& const Trange&, std::unique_ptr<wreport::Var>)
 
void seti (const Level &lev, const Trange &tr, wreport::Varcode code, int val, int conf)
 
void setd (const Level &lev, const Trange &tr, wreport::Varcode code, double val, int conf)
 
void setc (const Level &lev, const Trange &tr, wreport::Varcode code, const char *val, int conf)
 
virtual const wreport::Varget_impl (const Level &lev, const Trange &tr, wreport::Varcode code) const =0
 Implementation of get(const Level&, const Trange&, wreport::Varcode)
 
virtual void set_impl (const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var)=0
 Implementation of set(const Level& const Trange&, std::unique_ptr<wreport::Var>)
 

Detailed Description

Storage for related physical data.

Member Function Documentation

◆ clone()

std::shared_ptr< dballe::Message > dballe::impl::Message::clone ( ) const
overridevirtual

Return a copy of this message.

Implements dballe::Message.

◆ diff()

unsigned dballe::impl::Message::diff ( const dballe::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/3]

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

Return a reference to o downcasted as an impl::Message.

Throws an exception if o is not an impl::Message.

◆ downcast() [2/3]

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

Return a reference to o downcasted as an impl::Message.

Throws an exception if o is not an impl::Message.

◆ downcast() [3/3]

static std::shared_ptr< Message > dballe::impl::Message::downcast ( std::shared_ptr< dballe::Message o)
static

Returns a pointer to o downcasted as an impl::Message.

Throws an exception if o is not an impl::Message.

◆ edit()

wreport::Var * dballe::impl::Message::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_context()

msg::Context * dballe::impl::Message::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_context()

const msg::Context * dballe::impl::Message::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_station_context()

const Values & dballe::impl::Message::find_station_context ( ) const

Find the station info context.

Returns
The context found, or NULL if it was not found.

◆ foreach_var()

bool dballe::impl::Message::foreach_var ( std::function< bool(const Level &, const Trange &, const wreport::Var &)>  ) const
overridevirtual

Iterate the contents of the message.

Implements dballe::Message.

◆ from_csv()

bool dballe::impl::Message::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::impl::Message::get ( const Shortcut shortcut) const

Find a datum given its shortcut.

Parameters
shortcutShortcut of the value to set.
Returns
The value found, or nullptr if it was not found.

◆ get_coords()

Coords dballe::impl::Message::get_coords ( ) const
overridevirtual

Get the reference coordinates for this message.

Implements dballe::Message.

◆ get_datetime()

Datetime dballe::impl::Message::get_datetime ( ) const
overridevirtual

Get the reference Datetime for this message.

Implements dballe::Message.

◆ get_ident()

Ident dballe::impl::Message::get_ident ( ) const
overridevirtual

Get the station identifier for this message.

Implements dballe::Message.

◆ get_impl()

const wreport::Var * dballe::impl::Message::get_impl ( const Level lev,
const Trange tr,
wreport::Varcode  code 
) const
overrideprotectedvirtual

Implementation of get(const Level&, const Trange&, wreport::Varcode)

Implements dballe::Message.

◆ get_report()

std::string dballe::impl::Message::get_report ( ) const
overridevirtual

Get the report for this message.

Implements dballe::Message.

◆ get_type()

MessageType dballe::impl::Message::get_type ( ) const
inlineoverridevirtual

Return the type of the data in the message.

Implements dballe::Message.

References type.

◆ obtain_context()

msg::Context & dballe::impl::Message::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

◆ print()

void dballe::impl::Message::print ( FILE *  out) const
overridevirtual

Print all the contents of this message to an output stream.

Implements dballe::Message.

◆ query_data()

std::shared_ptr< dballe::CursorData > dballe::impl::Message::query_data ( const Query query) const
overridevirtual

Query the variables in the message.

Parameters
queryThe query data (note: currently ignored)
Returns
The cursor to use to iterate over the results

Implements dballe::Message.

◆ query_station_data()

std::shared_ptr< dballe::CursorStationData > dballe::impl::Message::query_station_data ( const Query query) const
overridevirtual

Query the station variables in the message.

Parameters
queryThe query data (note: currently ignored)
Returns
The cursor to use to iterate over the results

Implements dballe::Message.

◆ query_stations()

std::shared_ptr< dballe::CursorStation > dballe::impl::Message::query_stations ( const Query query) const
overridevirtual

Return a Cursor to access the station information in the message.

The cursor will have only one result, with the one station present in the message, contain all station vars.

Parameters
queryThe query data (note: currently ignored)
Returns
The cursor to use to iterate over the results

Implements dballe::Message.

◆ remove_context()

bool dballe::impl::Message::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()

void dballe::impl::Message::set ( const Shortcut shortcut,
const wreport::Var var 
)

Add or replace a value.

Parameters
shortcutShortcut ID of the value to set
varThe Var with the value to set

◆ set_impl()

void dballe::impl::Message::set_impl ( const Level lev,
const Trange tr,
std::unique_ptr< wreport::Var var 
)
overrideprotectedvirtual

Implementation of set(const Level& const Trange&, std::unique_ptr<wreport::Var>)

Implements dballe::Message.

◆ sounding_pack_levels()

void dballe::impl::Message::sounding_pack_levels ( )

Remove the sounding significance from the level descriptions and pack 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: