Go to the documentation of this file.00001 #include <swri_profiler_tools/profile_database.h>
00002 #include <QDebug>
00003
00004 namespace swri_profiler_tools
00005 {
00006 ProfileDatabase::ProfileDatabase()
00007 {
00008 }
00009
00010 ProfileDatabase::~ProfileDatabase()
00011 {
00012 for (auto &item : profiles_) {
00013 delete item.second;
00014 }
00015 }
00016
00017 int ProfileDatabase::createProfile(const QString &name)
00018 {
00019
00020 int key = profiles_.size();
00021 while (profiles_.count(key) != 0) { key++; }
00022
00023
00024 profiles_[key] = new Profile();
00025 profiles_list_.push_back(key);
00026 Profile &profile = *(profiles_.at(key));
00027 profile.initialize(key, name);
00028
00029
00030
00031
00032 QObject::connect(&profile, SIGNAL(profileModified(int)),
00033 this, SIGNAL(profileModified(int)));
00034 QObject::connect(&profile, SIGNAL(nodesAdded(int)),
00035 this, SIGNAL(nodesAdded(int)));
00036 QObject::connect(&profile, SIGNAL(dataAdded(int)),
00037 this, SIGNAL(dataAdded(int)));
00038
00039 Q_EMIT profileAdded(key);
00040 return key;
00041 }
00042
00043 Profile& ProfileDatabase::profile(int key)
00044 {
00045 if (profiles_.count(key) == 0) {
00046 qWarning("Invalid profile key: %d", key);
00047 return invalid_profile_;
00048 }
00049
00050 return *(profiles_.at(key));
00051 }
00052
00053 const Profile& ProfileDatabase::profile(int key) const
00054 {
00055 if (profiles_.count(key) == 0) {
00056 qWarning("Invalid profile key: %d", key);
00057 return invalid_profile_;
00058 }
00059
00060 return *(profiles_.at(key));
00061 }
00062 }