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 //#include <boost/shared_ptr.hpp>
43 
44 #include "../../../rosbag_storage/include/rosbag/stream.h"
45 
46 namespace rosbag {
47 
50 {
51  friend class Stream;
52 
53 public:
54  ChunkedFile();
55  ~ChunkedFile();
56 
57  void openWrite (std::string const& filename);
58  void openRead (std::string const& filename);
59  void openReadWrite(std::string const& filename);
60 
61  void close();
62 
63  std::string getFileName() const;
64  uint64_t getOffset() const;
65  uint32_t getCompressedBytesIn() const;
66  bool isOpen() const;
67  bool good() const;
68 
69  void setReadMode(CompressionType type);
70  void setWriteMode(CompressionType type);
71 
72  // File I/O
73  void write(std::string const& s);
74  void write(void* ptr, size_t size);
75  void read(void* ptr, size_t size);
76  std::string getline();
77  bool truncate(uint64_t length);
78  void seek(uint64_t offset, int origin = std::ios_base::beg);
79  void decompress(CompressionType compression, uint8_t* dest, unsigned int dest_len, uint8_t* source, unsigned int source_len);
80 
81 private:
82  void open(std::string const& filename, std::string const& mode);
83  void clearUnused();
84 
85 private:
86  std::string filename_;
87  FILE* file_;
90  char* unused_;
91  int nUnused_;
92 
93  std::shared_ptr<StreamFactory> stream_factory_;
94 
95  std::shared_ptr<Stream> read_stream_;
96  std::shared_ptr<Stream> write_stream_;
97 };
98 
99 } // namespace rosbag
100 
101 #endif
std::shared_ptr< StreamFactory > stream_factory_
Definition: chunked_file.h:93
GLsizei GLsizei GLchar * source
std::shared_ptr< Stream > read_stream_
Definition: chunked_file.h:95
GLdouble s
ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed da...
Definition: chunked_file.h:49
#define isOpen(pFd)
Definition: sqlite3.c:46629
unsigned char uint8_t
Definition: stdint.h:78
uint64_t offset_
current position in the file
Definition: chunked_file.h:88
GLenum mode
GLsizeiptr size
int nUnused_
number of bytes of extra data read by compressed stream
Definition: chunked_file.h:91
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
std::shared_ptr< Stream > write_stream_
Definition: chunked_file.h:96
uint64_t compressed_in_
number of bytes written to current compressed stream
Definition: chunked_file.h:89
std::string filename_
path to file
Definition: chunked_file.h:86
Definition: bag.h:66
GLenum type
FILE * file_
file pointer
Definition: chunked_file.h:87
GLenum GLuint GLenum GLsizei length
char * unused_
extra data read by compressed stream
Definition: chunked_file.h:90
#define ROSBAG_DECL
#include <ros/macros.h> // for the DECL&#39;s
GLintptr offset
char * dest
Definition: lz4.h:697


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:43:16