dataMerger.cpp
Go to the documentation of this file.
1 
18 #include <ISM/tools/DataMerger.hpp>
19 
20 #include <iostream>
21 #include <string>
22 #include <vector>
23 #include <algorithm>
24 #include <set>
25 
26 #include <boost/program_options.hpp>
27 
28 using namespace ISM;
29 using namespace std;
30 namespace po = boost::program_options;
31 
32 int main (int argc, char** argv)
33 {
34  bool mergeRecordings = false;
35  bool mergeModels = false;
36 
37  po::options_description desc("Allowed options");
38  desc.add_options()
39  ("help,h", "produce help message")
40  ("target-file,t", po::value<string>()->default_value("record.sqlite"), "target file")
41  ;
42 
43  po::options_description required("Required");
44  required.add_options()
45  ("source-file,s", po::value<vector<string> >(), "source file (precede each path by -s)")
46  ;
47 
48  po::options_description atLeastOne("At least one of these");
49  atLeastOne.add_options()
50  ("merge-recording,r", po::bool_switch(&mergeRecordings), "merge recordings")
51  ("merge-models,m", po::bool_switch(&mergeModels), "merge models")
52  ;
53 
54  desc.add(required);
55  desc.add(atLeastOne);
56 
57  po::variables_map vm;
58  po::store(po::parse_command_line(argc, argv, desc), vm);
59  po::notify(vm);
60 
61  if (vm.count("help") || !vm.count("target-file") || !vm.count("source-file") || (!mergeRecordings && !mergeModels))
62  {
63  cout << desc << "\n";
64  return 1;
65  }
66 
67  bool first = true;
68  vector<string> sourceFiles = vm["source-file"].as<vector<string> >();
69  string targetFile = vm["target-file"].as<string>();
70 
71  cout<<"merging ";
72  for (string& source : sourceFiles)
73  {
74  if (!first)
75  {
76  cout<<",";
77  }
78  else
79  {
80  first = false;
81  }
82  cout<<source;
83  }
84  cout<<" into "<<targetFile<<endl;
85  cout<<"Type yes to continue"<<endl;
86  string yes;
87  cin>>yes;
88  transform(yes.begin(), yes.end(), yes.begin(), ::tolower);
89  if (yes != "yes")
90  {
91  cout<<"aborting"<<endl;
92  return 1;
93  }
94 
95  //actual merging process
96  DataMerger data_merger;
97  data_merger.merge(targetFile, sourceFiles,mergeRecordings, mergeModels);
98 }
void merge(const std::string &targetFile, const std::vector< std::string > &sourceFiles, bool mergeRecordings, bool mergeModels)
Definition: DataMerger.cpp:26
int main(int argc, char **argv)
Definition: dataMerger.cpp:32
this namespace contains all generally usable classes.


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40