libdballe  5.18
msg/context.h
Go to the documentation of this file.
1 /*
2  * msg/context - Hold variables with the same physical context
3  *
4  * Copyright (C) 2005--2011 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBA_MSG_CONTEXT_H
23 #define DBA_MSG_CONTEXT_H
24 
31 #include <dballe/core/var.h>
32 #include <dballe/core/defs.h>
33 #include <vector>
34 #include <memory>
35 
36 struct lua_State;
37 
38 namespace dballe {
39 namespace msg {
40 
44 class Context
45 {
46 protected:
50  int find_index(wreport::Varcode code) const;
51 
52 public:
53  Level level;
54  Trange trange;
55 
59  std::vector<wreport::Var*> data;
60 
61  Context(const Level& lev, const Trange& tr);
62  Context(const Context& c);
63  ~Context();
64 
65  Context& operator=(const Context& src);
66 
68  bool is_station() const;
69 
78  int compare(const Context& ctx) const;
79 
87  int compare(const Level& lev, const Trange& tr) const;
88 
97  void set(const wreport::Var& var);
98 
109  void set(std::auto_ptr<wreport::Var> var);
110 
119  const wreport::Var* find(wreport::Varcode code) const;
120 
129  wreport::Var* edit(wreport::Varcode code);
130 
139  bool remove(wreport::Varcode code);
140 
149  const wreport::Var* find_by_id(int id) const;
150 
156  const wreport::Var* find_vsig() const;
157 
164  void print(FILE* out) const;
165 
177  unsigned diff(const Context& ctx) const;
178 
182  void lua_push(struct lua_State* L);
183 
189  static Context* lua_check(struct lua_State* L, int idx);
190 };
191 
192 
193 
194 #if 0
195 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);
196 dba_err dba_msg_context_set_by_id(dba_msg msg, dba_var var, int id);
197 dba_err dba_msg_context_set_nocopy_by_id(dba_msg msg, dba_var var, int id);
198 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);
199 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);
200 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);
201 #endif
202 
203 #if 0
204 
205 
206 
207 #endif
208 
209 }
210 }
211 
212 // vim:set ts=4 sw=4:
213 #endif