profile_database.cpp
Go to the documentation of this file.
2 #include <QDebug>
3 
4 namespace swri_profiler_tools
5 {
7 {
8 }
9 
11 {
12  for (auto &item : profiles_) {
13  delete item.second;
14  }
15 }
16 
17 int ProfileDatabase::createProfile(const QString &name)
18 {
19  // Find an available key
20  int key = profiles_.size();
21  while (profiles_.count(key) != 0) { key++; }
22 
23  // We are creating a new key
24  profiles_[key] = new Profile();
25  profiles_list_.push_back(key);
26  Profile &profile = *(profiles_.at(key));
27  profile.initialize(key, name);
28 
29  // We rebroadcast the individual profile signals in bulk so that
30  // other objects can just connect to us and not deal with
31  // adding/removing connections as profiles are added or deleted.
32  QObject::connect(&profile, SIGNAL(profileModified(int)),
33  this, SIGNAL(profileModified(int)));
34  QObject::connect(&profile, SIGNAL(nodesAdded(int)),
35  this, SIGNAL(nodesAdded(int)));
36  QObject::connect(&profile, SIGNAL(dataAdded(int)),
37  this, SIGNAL(dataAdded(int)));
38 
39  Q_EMIT profileAdded(key);
40  return key;
41 }
42 
44 {
45  if (profiles_.count(key) == 0) {
46  qWarning("Invalid profile key: %d", key);
47  return invalid_profile_;
48  }
49 
50  return *(profiles_.at(key));
51 }
52 
53 const Profile& ProfileDatabase::profile(int key) const
54 {
55  if (profiles_.count(key) == 0) {
56  qWarning("Invalid profile key: %d", key);
57  return invalid_profile_;
58  }
59 
60  return *(profiles_.at(key));
61 }
62 } // namespace swri_profiler_tools
std::unordered_map< int, Profile * > profiles_
void profileModified(int profile_key)
void nodesAdded(int profile_key)
void initialize(int profile_key, const QString &name)
Definition: profile.cpp:63
int createProfile(const QString &name)
void profileAdded(int profile_key)


swri_profiler_tools
Author(s):
autogenerated on Fri Nov 27 2020 03:44:18