DataMerger.cpp
Go to the documentation of this file.
1 
19 #include "DataMerger.hpp"
20 #include "../utility/TableHelper.hpp"
21 
22 #include <set>
23 
24 namespace ISM
25 {
26 void DataMerger::merge(const std::string& targetFile, const std::vector<std::string>& sourceFiles, bool mergeRecordings, bool mergeModels)
27 {
28  TableHelper target(targetFile);
29  for (const std::string& sourceFile : sourceFiles)
30  {
31  TableHelper source(sourceFile);
32  std::cout << sourceFile << ":" << std::endl;
33 
34  if (mergeRecordings)
35  {
36  std::cout << "merging recordings" << std::endl;
37  std::vector<std::string> patternNames = source.getRecordedPatternNames();
38  std::cout << "found " << patternNames.size() << " patterns" << std::endl;
39  for (const std::string& patternName : patternNames)
40  {
41  std::cout << "merge pattern " << patternName << std::endl;
43  for (const ObjectSetPtr& set : pattern->objectSets)
44  {
46  std::cout << ".";
47  std::cout.flush();
48  }
49  std::cout << "done" << std::endl;
50  }
51  }
52 
53  if (mergeModels)
54  {
55  std::cout << "merging models" << std::endl;
56  std::set<std::string> objectTypes = source.getObjectTypes();
57  std::cout << "found " << objectTypes.size() << " object types" << std::endl;
58  ObjectTypeToVoteMap typeToVoteMap = source.getVoteSpecifiersForObjectTypes(objectTypes);
59  std::set<std::string> patternNames;
60  for (const std::pair<std::string, std::vector<VoteSpecifierPtr>>& typeToVoteVecPair : typeToVoteMap)
61  {
62  std::string type = typeToVoteVecPair.first;
63  std::vector<VoteSpecifierPtr> voteVec = typeToVoteVecPair.second;
64  std::cout << "found " << voteVec.size() << " votes for object type " << type << std::endl;
65  for (VoteSpecifierPtr& vote : voteVec) {
66  patternNames.insert(vote->patternName);
67  target.insertModelVoteSpecifier(vote);
68  std::cout << ".";
69  std::cout.flush();
70  }
71  std::cout << "done" << std::endl;
72  }
73 
74  PatternNameToPatternMap patternMap = source.getPatternDefinitionsByName(patternNames);
75  std::cout << "found " << patternMap.size() << " patterns" << std::endl;
76  for (const std::pair<std::string, PatternPtr>& patternNameToPattern : patternMap)
77  {
78  PatternPtr pattern = patternNameToPattern.second;
79  target.upsertModelPattern(pattern->name, pattern->expectedMaxWeight);
80  std::cout << ".";
81  std::cout.flush();
82  }
83  std::cout << "done" << std::endl;
84  }
85  }
86 }
87 }
void merge(const std::string &targetFile, const std::vector< std::string > &sourceFiles, bool mergeRecordings, bool mergeModels)
Definition: DataMerger.cpp:26
int insertRecordedObjectSet(const boost::shared_ptr< ObjectSet > &os, const std::string &patternName)
std::string patternName
boost::shared_ptr< RecordedPattern > RecordedPatternPtr
const std::set< std::string > getObjectTypes() const
const PatternNameToPatternMap getPatternDefinitionsByName(const std::set< std::string > &patternNames) const
boost::shared_ptr< Pattern > PatternPtr
Definition: Pattern.hpp:36
boost::shared_ptr< VoteSpecifier > VoteSpecifierPtr
int insertModelVoteSpecifier(const VoteSpecifierPtr &vote) const
boost::shared_ptr< ObjectSet > ObjectSetPtr
Definition: ObjectSet.hpp:53
std::map< std::string, PatternPtr > PatternNameToPatternMap
Definition: TableHelper.hpp:37
std::vector< std::string > getRecordedPatternNames() const
this namespace contains all generally usable classes.
int upsertModelPattern(const std::string &patternName, int expectedMaxWeight) const
std::map< std::string, std::vector< VoteSpecifierPtr > > ObjectTypeToVoteMap
Definition: TableHelper.hpp:36
const ObjectTypeToVoteMap getVoteSpecifiersForObjectTypes(const std::set< std::string > &objectTypes) const
const RecordedPatternPtr getRecordedPattern(const std::string &patternName) const


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