fake_file_writer.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_
00018 #define CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_
00019 
00020 #include <memory>
00021 #include <string>
00022 #include <vector>
00023 
00024 #include "cartographer/io/file_writer.h"
00025 
00026 namespace cartographer {
00027 namespace io {
00028 
00029 // Fakes a FileWriter by just writing the data to a std::vector<char>.
00030 class FakeFileWriter : public FileWriter {
00031  public:
00032   FakeFileWriter(const std::string& filename,
00033                  std::shared_ptr<std::vector<char>> content);
00034   ~FakeFileWriter() override = default;
00035 
00036   bool WriteHeader(const char* data, size_t len) override;
00037   bool Write(const char* data, size_t len) override;
00038   bool Close() override;
00039   std::string GetFilename() override;
00040 
00041  private:
00042   bool is_closed_;
00043   std::shared_ptr<std::vector<char>> content_;
00044   std::string filename_;
00045 };
00046 
00047 }  // namespace io
00048 }  // namespace cartographer
00049 
00050 #endif  // CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35