Gazebo Transport

API Reference

13.4.0
Recorder.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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 #ifndef GZ_TRANSPORT_LOG_RECORDER_HH_
18 #define GZ_TRANSPORT_LOG_RECORDER_HH_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <regex>
23 #include <set>
24 #include <string>
25 
26 #include <gz/transport/Clock.hh>
27 #include <gz/transport/config.hh>
28 #include <gz/transport/log/Export.hh>
29 
30 namespace gz
31 {
32  namespace transport
33  {
34  namespace log
35  {
36  // Inline bracket to help doxygen filtering.
37  inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
38  //
39  enum class RecorderError : int64_t
40  {
41  SUCCESS = 0,
42  FAILED_TO_OPEN = -1,
44  ALREADY_RECORDING = -3,
45  INVALID_TOPIC = -4,
46  TOPIC_NOT_FOUND = -5,
48  };
49 
54  class GZ_TRANSPORT_LOG_VISIBLE Recorder
55  {
57  public: Recorder();
58 
61  public: Recorder(Recorder &&_old); // NOLINT
62 
64  public: ~Recorder();
65 
72  public: RecorderError Sync(const Clock *_clockIn);
73 
78  public: RecorderError Start(const std::string &_file);
79 
83  public: void Stop();
84 
90  public: RecorderError AddTopic(const std::string &_topic);
91 
99  public: int64_t AddTopic(const std::regex &_topic);
100 
104  public: std::string Filename() const;
105 
109  public: const std::set<std::string> &Topics() const;
110 
114  public: std::size_t BufferSize() const;
115 
121  public: void SetBufferSize(std::size_t _size);
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
133  private: std::unique_ptr<Implementation> dataPtr;
134 #ifdef _WIN32
135 #pragma warning(pop)
136 #endif
137  };
138  }
139  }
140  }
141 }
142 #endif