files_container.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <string>
7 #include <tuple>
8 #include <mutex>
9 #include <fstream>
10 #include <list>
11 
12 #include "rosbag_content.h"
13 #include "print_helpers.h"
14 
16 {
18  {
19  public:
20  size_t size()
21  {
22  std::lock_guard<std::mutex> lock(mutex);
23  return m_files.size();
24  }
26  {
27  std::lock_guard<std::mutex> lock(mutex);
28  if (index >= m_files.size())
29  throw std::out_of_range(std::string("index: ") + std::to_string(index));
30 
31  auto itr = m_files.begin();
32  std::advance(itr, index);
33  return *itr;
34  }
35  int remove_file(int index)
36  {
37  std::lock_guard<std::mutex> lock(mutex);
38  if (index >= m_files.size())
39  throw std::out_of_range(std::string("index: ") + std::to_string(index));
40 
41  auto it_to_remove = m_files.begin();
42  std::advance(it_to_remove, index);
43  auto it = m_files.erase(it_to_remove);
44  return std::distance(m_files.begin(), it);
45  }
46  void AddFiles(std::vector<std::string> const& files)
47  {
48  std::lock_guard<std::mutex> lock(mutex);
49 
50  for (auto&& file : files)
51  {
52  try
53  {
54  if (std::find_if(m_files.begin(), m_files.end(), [file](const rosbag_content& r) { return r.path == file; }) != m_files.end())
55  {
56  throw std::runtime_error(tmpstringstream() << "File \"" << file << "\" already loaded");
57  }
58  m_files.emplace_back(file);
59  }
60  catch (const std::exception& e)
61  {
62  last_error_message += e.what();
63  last_error_message += "\n";
64  }
65  }
66  }
67  bool has_errors() const
68  {
69  return !last_error_message.empty();
70  }
72  {
73  return last_error_message;
74  }
75  void clear_errors()
76  {
77  last_error_message.clear();
78  }
79  private:
80  std::mutex mutex;
81  std::list<rosbag_content> m_files;
83  };
84 }
static const textual_icon lock
Definition: model-views.h:218
rosbag_content & operator[](int index)
void AddFiles(std::vector< std::string > const &files)
GLsizei const GLchar *const * string
e
Definition: rmse.py:177
GLsizei GLsizei GLfloat distance
Definition: glext.h:10563
GLuint index
GLdouble GLdouble r
files_container files
static auto it
std::list< rosbag_content > m_files
unsigned char advance
std::string to_string(T value)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:14