DLS  1.6
Chunk.h
1 /******************************************************************************
2  *
3  * This file is part of the Data Logging Service (DLS).
4  *
5  * DLS is free software: you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation, either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * DLS is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with DLS. If not, see <http://www.gnu.org/licenses/>.
17  *
18  *****************************************************************************/
19 
20 #ifndef LibDLSChunkH
21 #define LibDLSChunkH
22 
23 /*****************************************************************************/
24 
25 #include <string>
26 
27 #include "Exception.h"
28 #include "Time.h"
29 #include "Data.h"
30 #include "globals.h"
31 
32 /*****************************************************************************/
33 
34 namespace DlsProto {
35  class ChunkInfo;
36 }
37 
38 namespace LibDLS {
39 
40 /*****************************************************************************/
41 
42 template <class T> class IndexT;
43 class File;
44 template <class T> class CompressionT;
45 class XmlTag;
46 
47 /*****************************************************************************/
48 
54 typedef int (*DataCallback)(Data *, void *);
55 
56 /*************************************************************************/
57 
61  public Exception
62 {
63  public:
64  ChunkException(const std::string &pmsg):
65  Exception(pmsg) {};
66 };
67 
68 /*************************************************************************/
69 
73 {
74  public:
75  Chunk();
76  Chunk(const DlsProto::ChunkInfo &, ChannelType);
77  virtual ~Chunk();
78 
79  void import(const std::string &, ChannelType);
80  void preload(const std::string &, ChannelType, Time, Time);
81  void fetch_range();
82 
83  Time start() const { return _start; }
84  Time end() const { return _end; }
85  bool incomplete() const { return _incomplete; }
86 
87  void fetch_data(Time, Time, unsigned int,
88  DataCallback, void *,
89  unsigned int);
90 
91  bool operator<(const Chunk &) const;
92  bool operator==(const Chunk &) const;
93 
94  void set_chunk_info(DlsProto::ChunkInfo *) const;
95  void update_from_chunk_info(const DlsProto::ChunkInfo &);
96 
97 #ifdef DEBUG_TIMING
98  static void reset_timing();
99  static void output_timing();
100 #endif
101 
102  protected:
103  std::string _dir;
105  unsigned int _meta_reduction;
107  unsigned int _mdct_block_size;
111  bool _incomplete;
112  enum LoadState {
113  Empty,
114  Pre,
115  Full
116  } _load_state;
117 
118  unsigned int _calc_optimal_level(Time, Time, unsigned int) const;
119  Time _time_per_value(unsigned int) const;
120 
121  void _fetch_level_data_wrapper(Time, Time,
122  MetaType,
123  unsigned int,
124  Time,
125  Data **,
126  DataCallback,
127  void *,
128  unsigned int,
129  unsigned int &,
130  Time &) const;
131 
132  template <class T>
133  void _fetch_level_data(Time, Time,
134  MetaType,
135  unsigned int,
136  Time,
137  Data **,
138  DataCallback,
139  void *,
140  unsigned int,
141  unsigned int &,
142  Time &) const;
143 
144  template <class T>
145  bool _read_tag(
146  IndexT<IndexRecord> &,
147  unsigned int,
148  IndexRecord &,
149  IndexRecord &,
150  bool &,
151  File &,
152  CompressionT<T> *,
153  MetaType,
154  unsigned int,
155  Time,
156  Data **,
157  DataCallback,
158  void *,
159  unsigned int,
160  unsigned int &,
161  Time &
162  ) const;
163 
164  template <class T>
165  void _process_data_tag(const XmlTag *,
166  Time,
167  MetaType,
168  unsigned int,
169  Time,
170  CompressionT<T> *,
171  Data **,
172  DataCallback,
173  void *,
174  unsigned int,
175  unsigned int &,
176  Time &) const;
177 };
178 
179 /*****************************************************************************/
180 
181 } // namespace
182 
183 /*****************************************************************************/
184 
185 #endif
bool _incomplete
Data ist still logged.
Definition: Chunk.h:111
Chunk.
Definition: Chunk.h:72
Time _start
Startzeit des Chunks.
Definition: Chunk.h:108
Base class for all LibDLS exceptions.
Definition: Exception.h:36
unsigned int _meta_reduction
Meta-Untersetzung.
Definition: Chunk.h:105
Global data structures and functions.
MetaType
Meta type for recorded data.
Definition: globals.h:103
Block of data values.
Definition: Data.h:40
Index record for a data file index as part of a chunk.
Definition: globals.h:159
unsigned int _mdct_block_size
MDCT-Blockgroesse.
Definition: Chunk.h:107
double _sample_frequency
Abtastfrequenz.
Definition: Chunk.h:104
Definition: Channel.h:44
ChannelType _type
channel type
Definition: Chunk.h:110
int _format_index
Kompressionsformat.
Definition: Chunk.h:106
Datentyp zur Speicherung der Zeit in Mikrosekunden.
Definition: Time.h:46
Chunk Exception.
Definition: Chunk.h:60
DLS_PUBLIC bool operator<(const RealChannel &a, const RealChannel &b)
Less operator for sorting RealChannel lists.
#define DLS_PUBLIC
Macro for public method definitions (empty on non-win32).
Definition: globals.h:57
ChannelType
Basic DLS channel datatype.
Definition: globals.h:73
Time _end
Endzeit des Chunks.
Definition: Chunk.h:109
std::string _dir
Chunk-Verzeichnis.
Definition: Chunk.h:103