00001 // ***************************************************************************** 00002 // 00003 // Copyright (c) 2015, Southwest Research Institute® (SwRI®) 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // * Redistributions of source code must retain the above copyright 00009 // notice, this list of conditions and the following disclaimer. 00010 // * Redistributions in binary form must reproduce the above copyright 00011 // notice, this list of conditions and the following disclaimer in the 00012 // documentation and/or other materials provided with the distribution. 00013 // * Neither the name of Southwest Research Institute® (SwRI®) nor the 00014 // names of its contributors may be used to endorse or promote products 00015 // derived from this software without specific prior written permission. 00016 // 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE 00021 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00023 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00024 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00027 // DAMAGE. 00028 // 00029 // ***************************************************************************** 00030 00031 #ifndef SWRI_PROFILER_TOOLS_PROFILE_DATABASE_H_ 00032 #define SWRI_PROFILER_TOOLS_PROFILE_DATABASE_H_ 00033 00034 #include <unordered_map> 00035 00036 #include <QObject> 00037 #include <swri_profiler_tools/new_profile_data.h> 00038 #include <swri_profiler_tools/profile.h> 00039 00040 namespace swri_profiler_tools 00041 { 00042 class ProfileDatabase : public QObject 00043 { 00044 Q_OBJECT; 00045 00046 Profile invalid_profile_; 00047 00048 // We have to store these as pointers if we want to use an unordered 00049 // map because the map relies on operations that Qt doesn't permit 00050 // on QObject descendents. 00051 std::unordered_map<int, Profile*> profiles_; 00052 // This provides stable ordering for the profiles. 00053 std::vector<int> profiles_list_; 00054 00055 public: 00056 ProfileDatabase(); 00057 ~ProfileDatabase(); 00058 00059 int createProfile(const QString &name); 00060 00061 std::vector<int> profileKeys() const { return profiles_list_; } 00062 00063 Profile& profile(int key); 00064 const Profile& profile(int key) const; 00065 00066 Q_SIGNALS: 00067 void profileAdded(int profile_key); 00068 void profileModified(int profile_key); 00069 void nodesAdded(int profile_key); 00070 void dataAdded(int profile_key); 00071 }; // class ProfileDatabase 00072 } // namespace swri_profiler_tools 00073 #endif // SWRI_PROFILER_TOOLS_PROFILE_DATABASE_H_