儲存庫 vbox 的更動 66610
- 時間撮記:
- 2017-4-19 下午01:58:10 (8 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDefs.cpp
r62493 r66610 5 5 6 6 /* 7 * Copyright (C) 2011-201 6Oracle Corporation7 * Copyright (C) 2011-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDefs.h
r65690 r66610 5 5 6 6 /* 7 * Copyright (C) 2011-201 6Oracle Corporation7 * Copyright (C) 2011-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 21 21 /* Qt includes: */ 22 #include <QMap> 23 #include <QPair> 22 24 #include <QString> 23 #include <QPair>24 #include <QMap>25 25 26 26 /* COM includes: */ 27 27 #include "COMEnums.h" 28 28 29 29 30 /** Settings configuration namespace. */ … … 49 50 } 50 51 51 /* Template to operate settings cache item: */ 52 53 /** Template organizing settings object cache: */ 52 54 template <class CacheData> class UISettingsCache 53 55 { 54 56 public: 55 57 56 /* Creates empty cache item:*/58 /** Constructs empty object cache. */ 57 59 UISettingsCache() { m_value = qMakePair(CacheData(), CacheData()); } 58 60 61 /** Destructs cache object. */ 59 62 virtual ~UISettingsCache() { /* Makes MSC happy */ } 60 63 61 /* Returns the NON-modifiable REFERENCE to the initial cached data:*/62 const CacheData &base() const { return m_value.first; }63 /* Returns the NON-modifiable REFERENCE to the current cached data:*/64 const CacheData &data() const { return m_value.second; }65 /* Returns the modifiable REFERENCE to the current cached data:*/64 /** Returns the NON-modifiable REFERENCE to the initial cached data. */ 65 const CacheData &base() const { return m_value.first; } 66 /** Returns the NON-modifiable REFERENCE to the current cached data. */ 67 const CacheData &data() const { return m_value.second; } 68 /** Returns the modifiable REFERENCE to the current cached data. */ 66 69 CacheData &data() { return m_value.second; } 67 70 68 /* We assume that old cache item was removed if69 * initial data was set but current data was NOT set.70 * Returns 'true' if that cache item was removed:*/71 /** Returns whether the cached object was removed. 72 * We assume that cached object was removed if 73 * initial data was set but current data was NOT set. */ 71 74 virtual bool wasRemoved() const { return base() != CacheData() && data() == CacheData(); } 72 75 73 /* We assume that new cache item was created if74 * initial data was NOT set but current data was set.75 * Returns 'true' if that cache item was created:*/76 /** Returns whether the cached object was created. 77 * We assume that cached object was created if 78 * initial data was NOT set but current data was set. */ 76 79 virtual bool wasCreated() const { return base() == CacheData() && data() != CacheData(); } 77 80 78 /* We assume that old cache item was updated if79 * current and initial data were both set and not equal to each other.80 * Returns 'true' if that cache item was updated:*/81 /** Returns whether the cached object was updated. 82 * We assume that cached object was updated if 83 * current and initial data were both set and not equal to each other. */ 81 84 virtual bool wasUpdated() const { return base() != CacheData() && data() != CacheData() && data() != base(); } 82 85 83 /* We assume that old cache item was actually changed if 84 * 1. this item was removed or 85 * 2. this item was created or 86 * 3. this item was updated. 87 * Returns 'true' if that cache item was actually changed: */ 86 /** Returns whether the cached object was changed. 87 * We assume that cached object was changed if 88 * it was 1. removed, 2. created or 3. updated. */ 88 89 virtual bool wasChanged() const { return wasRemoved() || wasCreated() || wasUpdated(); } 89 90 90 /* Set initial cache item data:*/91 /** Defines initial cached object data. */ 91 92 void cacheInitialData(const CacheData &initialData) { m_value.first = initialData; } 92 /* Set current cache itemdata: */93 /** Defines current cached object data: */ 93 94 void cacheCurrentData(const CacheData ¤tData) { m_value.second = currentData; } 94 95 95 /* Reset the initial and the current data to be both empty:*/96 /** Resets the initial and the current object data to be both empty. */ 96 97 void clear() { m_value.first = CacheData(); m_value.second = CacheData(); } 97 98 98 99 private: 99 100 100 /* Data:*/101 /** Holds the cached object data. */ 101 102 QPair<CacheData, CacheData> m_value; 102 103 }; 103 104 104 /* Template to operate settings cache item with children: */ 105 106 /** Template organizing settings object cache with children. */ 105 107 template <class ParentCacheData, class ChildCacheData> class UISettingsCachePool : public UISettingsCache<ParentCacheData> 106 108 { 107 109 public: 108 110 109 /* Typedefs:*/111 /** Children map. */ 110 112 typedef QMap<QString, ChildCacheData> UISettingsCacheChildMap; 113 /** Children map iterator. */ 111 114 typedef QMapIterator<QString, ChildCacheData> UISettingsCacheChildIterator; 112 115 113 /* Creates empty cache item:*/116 /** Constructs empty object cache. */ 114 117 UISettingsCachePool() : UISettingsCache<ParentCacheData>() {} 115 118 116 /* Returns the modifiable REFERENCE to the particular child cached data.117 * If child with such key or index is NOT present,118 * both those methods will create the new one to return:*/119 /** Returns children count. */ 120 int childCount() const { return m_children.size(); } 121 /** Returns the modifiable REFERENCE to the child cached data. */ 119 122 ChildCacheData& child(const QString &strChildKey) { return m_children[strChildKey]; } 123 /** Wraps method above to return the modifiable REFERENCE to the child cached data. */ 120 124 ChildCacheData& child(int iIndex) { return child(indexToKey(iIndex)); } 121 122 /* Returns the NON-modifiable COPY to the particular child cached data. 123 * If child with such key or index is NOT present, 124 * both those methods will create the new one to return: */ 125 /** Returns the NON-modifiable COPY to the child cached data. */ 125 126 const ChildCacheData child(const QString &strChildKey) const { return m_children[strChildKey]; } 127 /** Wraps method above to return the NON-modifiable COPY to the child cached data. */ 126 128 const ChildCacheData child(int iIndex) const { return child(indexToKey(iIndex)); } 127 129 128 /* Children count: */ 129 int childCount() const { return m_children.size(); } 130 131 /* We assume that old cache item was updated if 132 * current and initial data were both set and not equal to each other. 133 * Takes into account all the children. 134 * Returns 'true' if that cache item was updated: */ 130 /** Returns whether the cache was updated. 131 * We assume that cache object was updated if current and 132 * initial data were both set and not equal to each other. 133 * Takes into account all the children. */ 135 134 bool wasUpdated() const 136 135 { 137 /* First of all, cache itemis considered to be updated if parent data was updated: */136 /* First of all, cache object is considered to be updated if parent data was updated: */ 138 137 bool fWasUpdated = UISettingsCache<ParentCacheData>::wasUpdated(); 139 /* If parent data was NOT updated but also was NOT created or removed too (e.j. was NOT changed at all),140 * we have to check children too: */138 /* If parent data was NOT updated but also was NOT created or removed too 139 * (e.j. was NOT changed at all), we have to check children too: */ 141 140 if (!fWasUpdated && !UISettingsCache<ParentCacheData>::wasRemoved() && !UISettingsCache<ParentCacheData>::wasCreated()) 142 141 { … … 148 147 } 149 148 150 /* Reset the initial and the currentdata to be both empty.151 * Removes all the children:*/149 /** Resets the initial and the current one data to be both empty. 150 * Removes all the children. */ 152 151 void clear() 153 152 { … … 158 157 private: 159 158 159 /** Returns QString representation of passed @a iIndex. */ 160 160 QString indexToKey(int iIndex) const 161 161 { … … 170 170 } 171 171 172 /* Children:*/172 /** Holds the children. */ 173 173 UISettingsCacheChildMap m_children; 174 174 }; 175 175 176 176 #endif /* !___UISettingsDefs_h___ */ 177
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器