libdballe
5.18
|
00001 /* 00002 * msg/context - Hold variables with the same physical context 00003 * 00004 * Copyright (C) 2005--2011 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_CONTEXT_H 00023 #define DBA_MSG_CONTEXT_H 00024 00031 #include <dballe/core/var.h> 00032 #include <dballe/core/defs.h> 00033 #include <vector> 00034 #include <memory> 00035 00036 struct lua_State; 00037 00038 namespace dballe { 00039 namespace msg { 00040 00044 class Context 00045 { 00046 protected: 00050 int find_index(wreport::Varcode code) const; 00051 00052 public: 00053 Level level; 00054 Trange trange; 00055 00059 std::vector<wreport::Var*> data; 00060 00061 Context(const Level& lev, const Trange& tr); 00062 Context(const Context& c); 00063 ~Context(); 00064 00065 Context& operator=(const Context& src); 00066 00068 bool is_station() const; 00069 00078 int compare(const Context& ctx) const; 00079 00087 int compare(const Level& lev, const Trange& tr) const; 00088 00097 void set(const wreport::Var& var); 00098 00109 void set(std::auto_ptr<wreport::Var> var); 00110 00119 const wreport::Var* find(wreport::Varcode code) const; 00120 00129 wreport::Var* edit(wreport::Varcode code); 00130 00139 bool remove(wreport::Varcode code); 00140 00149 const wreport::Var* find_by_id(int id) const; 00150 00156 const wreport::Var* find_vsig() const; 00157 00164 void print(FILE* out) const; 00165 00177 unsigned diff(const Context& ctx) const; 00178 00182 void lua_push(struct lua_State* L); 00183 00189 static Context* lua_check(struct lua_State* L, int idx); 00190 }; 00191 00192 00193 00194 #if 0 00195 dba_err dba_msg_context_set(dba_msg msg, dba_var var, dba_varcode code, int ltype, int l1, int l2, int pind, int p1, int p2); 00196 dba_err dba_msg_context_set_by_id(dba_msg msg, dba_var var, int id); 00197 dba_err dba_msg_context_set_nocopy_by_id(dba_msg msg, dba_var var, int id); 00198 dba_err dba_msg_context_seti(dba_msg msg, dba_varcode code, int val, int conf, int ltype, int l1, int l2, int pind, int p1, int p2); 00199 dba_err dba_msg_context_setd(dba_msg msg, dba_varcode code, double val, int conf, int ltype, int l1, int l2, int pind, int p1, int p2); 00200 dba_err dba_msg_context_setc(dba_msg msg, dba_varcode code, const char* val, int conf, int ltype, int l1, int l2, int pind, int p1, int p2); 00201 #endif 00202 00203 #if 0 00204 00205 00206 00207 #endif 00208 00209 } 00210 } 00211 00212 // vim:set ts=4 sw=4: 00213 #endif