/usr/include/dballe/msg/wr_codec.h is in libdballe-dev 5.10-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | /*
* dballe/wr_codec - BUFR/CREX import and export
*
* Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Enrico Zini <enrico@enricozini.com>
*/
#ifndef DBALLE_MSG_WR_CODEC_H
#define DBALLE_MSG_WR_CODEC_H
#include <dballe/msg/codec.h>
#include <dballe/msg/msg.h>
#include <wreport/varinfo.h>
#include <stdint.h>
#include <map>
#include <string>
namespace wreport {
struct Bulletin;
struct Subset;
}
namespace dballe {
struct Msg;
namespace msg {
class WRImporter : public Importer
{
public:
WRImporter(const Options& opts);
/**
* Import a decoded BUFR/CREX message
*/
virtual void from_bulletin(const wreport::Bulletin& msg, Msgs& msgs) const;
};
class BufrImporter : public WRImporter
{
public:
BufrImporter(const Options& opts=Options());
virtual ~BufrImporter();
virtual void from_rawmsg(const Rawmsg& msg, Msgs& msgs) const;
};
class CrexImporter : public WRImporter
{
public:
CrexImporter(const Options& opts=Options());
virtual ~CrexImporter();
virtual void from_rawmsg(const Rawmsg& msg, Msgs& msgs) const;
};
class WRExporter : public Exporter
{
public:
WRExporter(const Options& opts);
/**
* Import a decoded BUFR/CREX message
*/
virtual void to_bulletin(const Msgs& msgs, wreport::Bulletin& msg) const;
/**
* Infer a template name from the message contents
*/
std::string infer_template(const Msgs& msgs) const;
};
class BufrExporter : public WRExporter
{
public:
BufrExporter(const Options& opts=Options());
virtual ~BufrExporter();
virtual void to_rawmsg(const Msgs& msgs, Rawmsg& msg) const;
virtual std::auto_ptr<wreport::Bulletin> make_bulletin() const;
};
class CrexExporter : public WRExporter
{
public:
CrexExporter(const Options& opts=Options());
virtual ~CrexExporter();
virtual void to_rawmsg(const Msgs& msgs, Rawmsg& msg) const;
virtual std::auto_ptr<wreport::Bulletin> make_bulletin() const;
};
namespace wr {
struct TemplateRegistry;
class Template
{
protected:
virtual void setupBulletin(wreport::Bulletin& bulletin);
virtual void to_subset(const Msg& msg, wreport::Subset& subset);
void add(wreport::Varcode code, const msg::Context* ctx, int shortcut) const;
void add(wreport::Varcode code, const msg::Context* ctx, wreport::Varcode srccode) const;
void add(wreport::Varcode code, const msg::Context* ctx) const;
void add(wreport::Varcode code, int shortcut) const;
void add(wreport::Varcode code, wreport::Varcode srccode, const Level& level, const Trange& trange) const;
void add(wreport::Varcode code, const wreport::Var* var) const;
// Set station name, truncating it if it's too long
void add_st_name(wreport::Varcode dstcode, const msg::Context* ctx) const;
void do_ecmwf_past_wtr() const;
void do_D01001() const;
void do_D01004() const;
void do_D01011() const;
int do_D01012() const; // Return the number of hours
void do_D01013() const;
void do_D01021() const;
public:
const Exporter::Options& opts;
const Msgs& msgs;
const Msg* msg; // Msg being read
const msg::Context* c_station;
const msg::Context* c_gnd_instant;
wreport::Subset* subset; // Subset being written
Template(const Exporter::Options& opts, const Msgs& msgs)
: opts(opts), msgs(msgs), msg(0), subset(0) {}
virtual ~Template() {}
virtual const char* name() const = 0;
virtual const char* description() const = 0;
virtual void to_bulletin(wreport::Bulletin& bulletin);
};
struct TemplateFactory
{
std::string name;
std::string description;
virtual ~TemplateFactory() {}
virtual std::auto_ptr<Template> make(const Exporter::Options& opts, const Msgs& msgs) const = 0;
};
struct TemplateRegistry : public std::map<std::string, const TemplateFactory*>
{
static const TemplateRegistry& get();
static const TemplateFactory& get(const std::string& name);
void register_factory(const TemplateFactory* fac);
};
} // namespace wr
#if 0
/** @file
* @ingroup bufrex
* High level encoding and decoding functions
*/
#include <dballe/core/rawmsg.h>
#include <dballe/msg/msgs.h>
#include <dballe/msg/codec.h>
#include <dballe/bufrex/msg.h>
/**
* Encode a dba_msg into a BUFR message
*
* @param msgs
* The message to encode
* @param type
* The type of the encoded message. Use 0 to let the encoder make a good choice.
* @param subtype
* The subtype of the encoded message. Use 0 to let the encoder make a good choice.
* @retval raw
* The raw encoded message
* @return
* The error status (See @ref error.h)
*/
dba_err bufrex_encode_bufr(dba_msgs msgs, int type, int subtype, int localsubtype, dba_rawmsg* raw);
/**
* Encode a dba_msg into a CREX message
*
* @param msgs
* The message to encode
* @param type
* The type of the encoded message. Use 0 to let the encoder make a good choice.
* @param subtype
* The subtype of the encoded message. Use 0 to let the encoder make a good choice.
* @retval raw
* The raw encoded message
* @return
* The error status (See @ref error.h)
*/
dba_err bufrex_encode_crex(dba_msgs msgs, int type, int subtype, dba_rawmsg* raw);
/**
* Fill in the bufrex_msg with the contents of a dba_msg
*
* @param raw
* The bufrex message that will be filled with the data from msg
* @param msg
* The dba_msg to take the data from
* @return
* The error indicator for the function (See @ref error.h)
*/
dba_err bufrex_msg_from_dba_msg(bufrex_msg raw, dba_msg msg);
/**
* Fill in the bufrex_msg with the contents of a dba_msgs
*
* @param raw
* The bufrex message that will be filled with the data from msg
* @param msgs
* The dba_msgs to take the data from
* @return
* The error indicator for the function (See @ref error.h)
*/
dba_err bufrex_msg_from_dba_msgs(bufrex_msg raw, dba_msgs msgs);
/**
* Fill in a dba_msgs with the contents of the bufrex_msg
*
* @param raw
* The bufrex message with the data to interpret
* @param opts
* Codec options
* @retval msgs
* The dba_msgs with the interpreted data
* @return
* The error indicator for the function (See @ref error.h)
*/
dba_err bufrex_msg_to_dba_msgs(bufrex_msg raw, dba_msg_codec_options opts, dba_msgs* msgs);
/**
* Infer good type and subtype from a dba_msg
*
* @param msg
* The message for which to infer the encoding template
* @retval type
* The type of the encoding template to use
* @retval subtype
* The subtype of the encoding template to use
* @return
* The error indicator for the function (See @ref error.h)
*/
dba_err bufrex_infer_type_subtype(dba_msg msg, int* type, int* subtype, int* localsubtype);
#endif
} // namespace msg
} // namespace dballe
/* vim:set ts=4 sw=4: */
#endif
|