libdballe
5.18
|
00001 /* 00002 * msg/codec - General codec options 00003 * 00004 * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * Author: Enrico Zini <enrico@enricozini.com> 00020 */ 00021 00022 #ifndef DBA_MSG_CODEC_H 00023 #define DBA_MSG_CODEC_H 00024 00025 #include <dballe/core/rawmsg.h> 00026 #include <dballe/core/defs.h> 00027 #include <memory> 00028 #include <string> 00029 #include <stdio.h> 00030 00036 namespace wreport { 00037 struct Bulletin; 00038 } 00039 00040 namespace dballe { 00041 struct Rawmsg; 00042 struct Msgs; 00043 00044 namespace msg { 00045 00053 class Importer 00054 { 00055 public: 00056 struct Options 00057 { 00058 bool simplified; 00059 00061 Options() 00062 : simplified(true) {} 00063 00065 void print(FILE* out); 00066 00068 std::string to_string() const; 00069 }; 00070 00071 protected: 00072 Options opts; 00073 00074 public: 00075 Importer(const Options& opts); 00076 virtual ~Importer(); 00077 00086 virtual void from_rawmsg(const Rawmsg& msg, Msgs& msgs) const = 0; 00087 00091 virtual void from_bulletin(const wreport::Bulletin& msg, Msgs& msgs) const = 0; 00092 00093 00095 static std::auto_ptr<Importer> create(Encoding type, const Options& opts=Options()); 00096 }; 00097 00105 class Exporter 00106 { 00107 public: 00108 struct Options 00109 { 00111 std::string template_name; 00113 int centre; 00115 int subcentre; 00117 int application; 00118 00120 Options() 00121 : centre(MISSING_INT), subcentre(MISSING_INT), application(MISSING_INT) {} 00122 00124 void print(FILE* out); 00125 00127 std::string to_string() const; 00128 }; 00129 00130 protected: 00131 Options opts; 00132 00133 public: 00134 Exporter(const Options& opts); 00135 virtual ~Exporter(); 00136 00145 virtual void to_rawmsg(const Msgs& msgs, Rawmsg& msg) const = 0; 00146 00150 virtual void to_bulletin(const Msgs& msgs, wreport::Bulletin& msg) const = 0; 00151 00158 virtual std::auto_ptr<wreport::Bulletin> make_bulletin() const; 00159 00160 00162 static std::auto_ptr<Exporter> create(Encoding type, const Options& opts=Options()); 00163 }; 00164 00165 } // namespace msg 00166 } // namespace dballe 00167 00168 /* vim:set ts=4 sw=4: */ 00169 #endif