meteo-vm2  2.0.11
source.h
Go to the documentation of this file.
1 /*
2  * source - Reader for VM2 attributes file
3  *
4  * Copyright (C) 2012,2013 Arpae-SIMC <simc-urp@arpae.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, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Author: Emanuele Di Giacomo <edigiacomo@arpae.it>
21  */
22 #ifndef METEO_VM2_SOURCE_H
23 #define METEO_VM2_SOURCE_H
30 #include <stdio.h>
31 #include <string>
32 #include <vector>
33 
34 #include <lua.hpp>
35 
36 namespace meteo {
37 namespace vm2 {
38 namespace source {
39 
45 std::string path();
46 
47 }
48 
57 struct CoreSource {
58  std::string path;
59  lua_State *L;
60 
61  int stations_ref;
62  int variables_ref;
63  int filter_ref;
64 
66  CoreSource(const std::string& path, lua_State* L);
68  ~CoreSource();
69 
71  void lua_push_station(int id);
73  void lua_push_variable(int id);
75  std::vector<int> lua_find_stations(int idx);
77  std::vector<int> lua_find_variables(int idx);
78 };
79 
83 class Source {
84  private:
85  static Source* instance;
86 
87  CoreSource* coresource;
88 
89  public:
91  lua_State* L;
92 
98  static Source* get();
99 
100  Source(const std::string& path);
101  ~Source();
102 
104  void lua_push_station(int id);
106  void lua_push_variable(int id);
108  std::vector<int> lua_find_stations(int idx);
110  std::vector<int> lua_find_variables(int idx);
111 };
112 
113 }
114 }
115 
116 #endif /* METEO_VM2_SOURCE_H */
void lua_push_station(int id)
Definition: source.cc:162
std::vector< int > lua_find_stations(int idx)
Definition: source.cc:168
static Source * get()
Definition: source.cc:145
std::vector< int > lua_find_variables(int idx)
Definition: source.cc:171
void lua_push_variable(int id)
Definition: source.cc:165
lua_State * L
Lua VM.
Definition: source.h:91
~CoreSource()
Unload the attributes.
Definition: source.cc:85
std::vector< int > lua_find_variables(int idx)
List of station id matching the table at the given index.
Definition: source.cc:123
void lua_push_variable(int id)
Push on top of the stack the variable attributes (or nil if not found)
Definition: source.cc:97
CoreSource(const std::string &path, lua_State *L)
Load the attributes file path in Lua VM L.
Definition: source.cc:59
std::vector< int > lua_find_stations(int idx)
List of station id matching the table at the given index.
Definition: source.cc:104
void lua_push_station(int id)
Push on top of the stack the station attributes (or nil if not found)
Definition: source.cc:91