pocolog_cpp
Format.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2013 DFKI
3  * Copyright (c) 2005-2006 LAAS/CNRS <openrobots@laas.fr>
4  * Sylvain Joyeux <sylvain.joyeux@m4x.org>
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
28  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
29  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
30  * DAMAGE.
31  */
32 
33 
34 #ifndef POCOLOG_CPP_FORMAT_H
35 #define POCOLOG_CPP_FORMAT_H
36 
37 #include <stdint.h>
38 #include <base/Time.hpp>
39 
100 namespace pocolog_cpp
101 {
102  // Version 1 is the same format without a prologue, and without the compression
103  // flag in data blocks
104  static const int FORMAT_VERSION = 2;
105  extern const char FORMAT_MAGIC[];
107  struct Prologue
108  {
109  char magic[7];
110  uint8_t padding;
112  uint32_t version;
113  uint32_t flags;
115  : padding(0), version(0), flags(0)
116  {
117  for (int i = 0; i < 7; ++i)
118  magic[i] = FORMAT_MAGIC[i];
119  }
120  } __attribute__ ((packed)) ;
121 
122  struct BlockHeader
123  {
124  uint8_t type;
125  uint8_t padding;
126  uint16_t stream_idx;
127  uint32_t data_size;
128  } __attribute__ ((packed));
129  static const int BLOCK_HEADER_SIZE = 8;
131  struct SampleHeaderData
132  {
133  uint32_t realtime_tv_sec;
137  uint32_t data_size;
138  uint8_t compressed;
139  } __attribute__ ((packed));
140 
142  {
143  base::Time realtime;
144  base::Time timestamp;
145  uint32_t data_size;
146  uint8_t compressed;
147  } ; //__attribute__ ((packed));
148  static const int SAMPLE_HEADER_SIZE = 21;
149 
150  enum BlockType
151  {
156  };
158  {
162  };
164  {
167  };
168 
172  {
173  std::string key;
174  std::string value;
175  };
176 };
177 
178 #endif
179 
uint8_t compressed
Definition: Format.hpp:138
Definition: Format.hpp:122
uint32_t data_size
Definition: Format.hpp:145
Definition: Format.hpp:153
uint32_t flags
Definition: Format.hpp:113
Definition: Format.hpp:152
Prologue()
Definition: Format.hpp:114
struct pocolog_cpp::SampleHeader __attribute__
uint8_t compressed
Definition: Format.hpp:146
const char FORMAT_MAGIC[]
Definition: Format.cpp:4
StreamType
Definition: Format.hpp:157
Definition: Format.hpp:161
uint32_t realtime_tv_usec
Definition: Format.hpp:134
uint32_t timestamp_tv_usec
Definition: Format.hpp:136
uint16_t stream_idx
Definition: Format.hpp:126
CommandType
Definition: Format.hpp:163
Definition: Format.hpp:141
uint8_t type
Definition: Format.hpp:124
std::string value
Definition: Format.hpp:174
base::Time realtime
Definition: Format.hpp:143
uint32_t realtime_tv_sec
Definition: Format.hpp:133
Definition: Format.hpp:160
Definition: Format.hpp:159
uint32_t version
Definition: Format.hpp:112
uint32_t data_size
Definition: Format.hpp:137
char magic[7]
Definition: Format.hpp:109
BlockType
Definition: Format.hpp:150
Definition: Format.hpp:171
Prologue()
Definition: Format.hpp:111
Definition: Format.hpp:165
std::string key
Definition: Format.hpp:173
uint32_t timestamp_tv_sec
Definition: Format.hpp:135
Definition: Format.hpp:166
base::Time timestamp
Definition: Format.hpp:144
stream declaration block
Definition: Format.hpp:154
a data block in an already declared stream
Definition: Format.hpp:155
uint32_t data_size
Definition: Format.hpp:127
uint8_t padding
Definition: Format.hpp:125
uint8_t padding
Definition: Format.hpp:110