Gazebo Transport

API Reference

12.2.1
gz/transport/log/Log.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
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 
18 #ifndef GZ_TRANSPORT_LOG_LOG_HH_
19 #define GZ_TRANSPORT_LOG_LOG_HH_
20 
21 #include <chrono>
22 #include <ios>
23 #include <memory>
24 #include <string>
25 
26 #include <gz/transport/config.hh>
30 #include <gz/transport/log/Export.hh>
31 
32 namespace gz
33 {
34  namespace transport
35  {
36  namespace log
37  {
38  // Inline bracket to help doxygen filtering.
39  inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
40  //
42  const std::string SchemaLocationEnvVar = "GZ_TRANSPORT_LOG_SQL_PATH";
43 
44  // TODO(CH3): Deprecated. Remove this on ticktock.
46  "IGN_TRANSPORT_LOG_SQL_PATH";
47 
49  class GZ_TRANSPORT_LOG_VISIBLE Log
50  {
52  public: Log();
53 
56  public: Log(Log &&_old); // NOLINT
57 
59  public: ~Log();
60 
63  public: bool Valid() const;
64 
68  public: std::string Version() const;
69 
76  public: bool Open(const std::string &_file,
77  std::ios_base::openmode _mode = std::ios_base::in);
78 
82  public: std::string Filename() const;
83 
89  public: const log::Descriptor *Descriptor() const;
90 
98  public: bool InsertMessage(
99  const std::chrono::nanoseconds &_time,
100  const std::string &_topic, const std::string &_type,
101  const void *_data, std::size_t _len);
102 
108  public: Batch QueryMessages(
109  const QueryOptions &_options = AllTopics());
110 
115  public: std::chrono::nanoseconds StartTime() const;
116 
121  public: std::chrono::nanoseconds EndTime() const;
122 
124  private: class Implementation;
125 
126 #ifdef _WIN32
127 // Disable warning C4251 which is triggered by
128 // std::*
129 #pragma warning(push)
130 #pragma warning(disable: 4251)
131 #endif
132  private: std::unique_ptr<Implementation> dataPtr;
134 #ifdef _WIN32
135 #pragma warning(pop)
136 #endif
137  };
138  }
139  }
140  }
141 }
142 #endif