Apollo  6.0
Open source self driving car software
record_file_base.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #ifndef CYBER_RECORD_FILE_RECORD_FILE_BASE_H_
18 #define CYBER_RECORD_FILE_RECORD_FILE_BASE_H_
19 
20 #include <mutex>
21 #include <string>
22 
23 #include "cyber/proto/record.pb.h"
24 
25 namespace apollo {
26 namespace cyber {
27 namespace record {
28 
29 const int HEADER_LENGTH = 2048;
30 
32  public:
33  RecordFileBase() = default;
34  virtual ~RecordFileBase() = default;
35  virtual bool Open(const std::string& path) = 0;
36  virtual void Close() = 0;
37  const std::string& GetPath() const { return path_; }
38  const proto::Header& GetHeader() const { return header_; }
39  const proto::Index& GetIndex() const { return index_; }
40  int64_t CurrentPosition();
41  bool SetPosition(int64_t position);
42 
43  protected:
44  std::mutex mutex_;
45  std::string path_;
46  proto::Header header_;
47  proto::Index index_;
48  int fd_ = -1;
49 };
50 
51 } // namespace record
52 } // namespace cyber
53 } // namespace apollo
54 
55 #endif // CYBER_RECORD_FILE_RECORD_FILE_BASE_H_
int fd_
Definition: record_file_base.h:48
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
proto::Header header_
Definition: record_file_base.h:46
virtual bool Open(const std::string &path)=0
const std::string & GetPath() const
Definition: record_file_base.h:37
Definition: record_file_base.h:31
bool SetPosition(int64_t position)
std::string path_
Definition: record_file_base.h:45
const int HEADER_LENGTH
Definition: record_file_base.h:29
const proto::Index & GetIndex() const
Definition: record_file_base.h:39
const proto::Header & GetHeader() const
Definition: record_file_base.h:38
proto::Index index_
Definition: record_file_base.h:47
std::mutex mutex_
Definition: record_file_base.h:44