libdballe  7.21
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/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::unique_ptr<wreport::Var> var);
110 
119  void seti(wreport::Varcode code, int val);
120 
129  void setd(wreport::Varcode code, double val);
130 
139  void setc(wreport::Varcode code, const char* val);
140 
149  const wreport::Var* find(wreport::Varcode code) const;
150 
160 
169  bool remove(wreport::Varcode code);
170 
179  const wreport::Var* find_by_id(int id) const;
180 
186  const wreport::Var* find_vsig() const;
187 
194  void print(FILE* out) const;
195 
207  unsigned diff(const Context& ctx) const;
208 
212  void lua_push(struct lua_State* L);
213 
219  static Context* lua_check(struct lua_State* L, int idx);
220 
221 #include <dballe/msg/context-extravars.h>
222 };
223 
224 
225 
226 #if 0
227 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);
228 dba_err dba_msg_context_set_by_id(dba_msg msg, dba_var var, int id);
229 dba_err dba_msg_context_set_nocopy_by_id(dba_msg msg, dba_var var, int id);
230 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);
231 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);
232 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);
233 #endif
234 
235 #if 0
236 
237 
238 
239 #endif
240 
241 }
242 }
243 
244 // vim:set ts=4 sw=4:
245 #endif
Store an array of physical data all on the same level.
Definition: context.h:44
void setc(wreport::Varcode code, const char *val)
Add or replace a string value.
int find_index(wreport::Varcode code) const
Return the index of the var `code&#39; in l, or -1 if it was not found.
Create wreport variables from the DB-All.e B table.
void setd(wreport::Varcode code, double val)
Add or replace a double value.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:587
std::vector< wreport::Var * > data
The variables in this context.
Definition: context.h:59
bool is_station() const
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Vertical level or layer.
Definition: types.h:532
uint16_t Varcode
void print(FILE *out) const
Dump all the contents of the context to the given stream.
const wreport::Var * find_vsig() const
If this context is the right context for a vertical sounding significance and contains a vertical sou...
const wreport::Var * find(wreport::Varcode code) const
Find a variable given its varcode.
void lua_push(struct lua_State *L)
Push the variable as an object in the lua stack.
static Context * lua_check(struct lua_State *L, int idx)
Check that the element at idx is a dba_msg_context.
wreport::Var * edit(wreport::Varcode code)
Find a variable given its varcode.
const wreport::Var * find_by_id(int id) const
Find a variable given its shortcut ID.
Common definitions.
int compare(const Context &ctx) const
Compare two dba_msg_context strutures, for use in sorting.
void seti(wreport::Varcode code, int val)
Add or replace an integer value.
unsigned diff(const Context &ctx) const
Compute the differences between two contexts.