chunked_file.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 ********************************************************************/
34 
35 #ifndef ROSBAG_CHUNKED_FILE_H
36 #define ROSBAG_CHUNKED_FILE_H
37 
38 #include <ios>
39 #include <stdint.h>
40 #include <string>
41 #include "macros.h"
42 
43 #include "../../../rosbag_storage/include/rosbag/stream.h"
44 
45 namespace rosbag {
46 
48 class ROSBAG_DECL ChunkedFile
49 {
50  friend class Stream;
51 
52 public:
53  ChunkedFile();
54  ~ChunkedFile();
55 
56  void openWrite (std::string const& filename);
57  void openRead (std::string const& filename);
58  void openReadWrite(std::string const& filename);
59 
60  void close();
61 
62  std::string getFileName() const;
63  uint64_t getOffset() const;
64  uint32_t getCompressedBytesIn() const;
65  bool isOpen() const;
66  bool good() const;
67 
68  void setReadMode(CompressionType type);
69  void setWriteMode(CompressionType type);
70 
71  // File I/O
72  void write(std::string const& s);
73  void write(void* ptr, size_t size);
74  void read(void* ptr, size_t size);
75  std::string getline();
76  bool truncate(uint64_t length);
77  void seek(uint64_t offset, int origin = std::ios_base::beg);
78  void decompress(CompressionType compression, uint8_t* dest, unsigned int dest_len, uint8_t* source, unsigned int source_len);
79 
80 private:
81  void open(std::string const& filename, std::string const& mode);
82  void clearUnused();
83 
84 private:
85  std::string filename_;
86  FILE* file_;
87  uint64_t offset_;
88  uint64_t compressed_in_;
89  char* unused_;
90  int nUnused_;
91 
92  std::shared_ptr<StreamFactory> stream_factory_;
93 
94  std::shared_ptr<Stream> read_stream_;
95  std::shared_ptr<Stream> write_stream_;
96 };
97 
98 } // namespace rosbag
99 
100 #endif
length
GLenum GLuint GLenum GLsizei length
Definition: glad/glad/glad.h:135
uint8_t
unsigned char uint8_t
Definition: stdint.h:78
offset
GLintptr offset
Definition: glad/glad/glad.h:2737
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
mode
GLenum mode
Definition: glad/glad/glad.h:1385
ROSBAG_DECL
#define ROSBAG_DECL
#include <ros/macros.h> // for the DECL's
Definition: rosbag_storage/include/rosbag/macros.h:43
type
GLenum type
Definition: glad/glad/glad.h:135
size
GLsizeiptr size
Definition: glad/glad/glad.h:2734
uint32_t
unsigned int uint32_t
Definition: stdint.h:80
uint64_t
unsigned __int64 uint64_t
Definition: stdint.h:90
stdint.h
source
GLsizei GLsizei GLchar * source
Definition: glad/glad/glad.h:2828
macros.h
test-projection-from-recording.filename
filename
Definition: test-projection-from-recording.py:15
dest
char * dest
Definition: lz4.h:697
rosbag::CompressionType
compression::CompressionType CompressionType
Definition: third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/stream.h:91
rosbag
Definition: bag.h:61
s
GLdouble s
Definition: glad/glad/glad.h:2441


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01