bag_manager.cpp
Go to the documentation of this file.
2 
4 {
5 BagManager::BagManager(const std::string &path,
6  const std::string &default_topic)
7  : default_topic_(default_topic)
8 {
9  boost::filesystem::create_directory(path);
10  int num = numOfFiles(path);
11  std::string name = path + "log_" + std::to_string(num) + ".bag";
12  ROS_DEBUG_STREAM("Opening a new bag: " << name);
14 }
15 
17 
18 int BagManager::numOfFiles(const std::string &path) const
19 {
20  // from http://www.cplusplus.com/forum/beginner/70854/
21  boost::filesystem::path p(path);
22  boost::filesystem::directory_iterator end_iter;
23  int num = 1;
24 
25  for (boost::filesystem::directory_iterator iter(p); iter != end_iter; iter++)
26  {
27  if (iter->path().extension() == ".bag")
28  {
29  num++;
30  }
31  }
32 
33  return num;
34 }
35 } // namespace generic_control_toolbox
void open(std::string const &filename, uint32_t mode=bagmode::Read)
void close()
int numOfFiles(const std::string &path) const
Definition: bag_manager.cpp:18
#define ROS_DEBUG_STREAM(args)
BagManager(const std::string &path, const std::string &default_topic)
Definition: bag_manager.cpp:5


generic_control_toolbox
Author(s): diogo
autogenerated on Mon Feb 28 2022 22:24:37