sbLocalDatabaseResourcePropertyBag.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2011 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef SBLOCALDATABASERESOURCEPROPERTYBAG_H_
28 #define SBLOCALDATABASERESOURCEPROPERTYBAG_H_
29 
30 #include <sbILocalDatabaseResourcePropertyBag.h>
31 
32 #include <nsClassHashtable.h>
33 #include <nsDataHashtable.h>
34 #include <nsStringAPI.h>
35 
36 #include <set>
37 
38 #include <sbIIdentityService.h>
39 
41 class sbIPropertyManager;
42 struct sbPropertyData;
43 
50 {
51 public:
53  NS_DECL_SBILOCALDATABASERESOURCEPROPERTYBAG
54 
56  PRUint32 mMediaItemId,
57  const nsAString& aGuid);
58 
60 
61  nsresult Init();
62  nsresult PutValue(PRUint32 aPropertyID,
63  const nsAString& aValue);
64 
65  PRBool IsPropertyDirty(PRUint32 aPropertyDBID);
66  nsresult EnumerateDirty(nsTHashtable<nsUint32HashKey>::Enumerator aEnumFunc, void *aClosure, PRUint32 *aDirtyCount);
67  nsresult ClearDirty();
68 
69  // Getting the dirty properties used for invalidation of GUID arrays will
70  // also clear them from the property bag.
71  nsresult GetDirtyForInvalidation(std::set<PRUint32> &aDirty);
72 
73 private:
74 
75  static PLDHashOperator PR_CALLBACK
76  PropertyBagKeysToArray(const PRUint32& aPropertyID,
78  void *aArg);
79 
81  nsClassHashtableMT<nsUint32HashKey, sbPropertyData> mValueMap;
82 
83  nsCOMPtr<sbIPropertyManager> mPropertyManager;
84  nsCOMPtr<sbIIdentityService> mIdService;
85 
86  nsString mGuid;
87  PRUint32 mMediaItemId;
88 
89  // Dirty Property ID's
90  nsTHashtable<nsUint32HashKey> mDirty;
91  // Dirty Property ID's used for invalidating GUID arrays.
92  std::set<PRUint32> mDirtyForInvalidation;
93 };
94 
101 {
102  sbPropertyData(const nsAString &aValue,
103  const nsAString &aSearchableValue,
104  const nsAString &aSortableValue) :
105  value(aValue),
106  searchableValue(aSearchableValue),
107  sortableValue(aSortableValue)
108  {};
109  nsString value;
110  nsString searchableValue;
111  nsString sortableValue;
112 };
113 
114 
115 #endif /* SBLOCALDATABASERESOURCEPROPERTYBAG_H_ */
nsresult EnumerateDirty(nsTHashtable< nsUint32HashKey >::Enumerator aEnumFunc, void *aClosure, PRUint32 *aDirtyCount)
onPageChanged aValue
Definition: FeedWriter.js:1395
NS_DECL_ISUPPORTS NS_DECL_SBILOCALDATABASERESOURCEPROPERTYBAG sbLocalDatabaseResourcePropertyBag(sbLocalDatabasePropertyCache *aCache, PRUint32 mMediaItemId, const nsAString &aGuid)
function Enumerator(aItemsList)
sbPropertyData(const nsAString &aValue, const nsAString &aSearchableValue, const nsAString &aSortableValue)
void * aClosure
Definition: sbArray.cpp:52
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
Manager for system wide metadata properties.
nsresult PutValue(PRUint32 aPropertyID, const nsAString &aValue)
_updateTextAndScrollDataForFrame aData
nsresult GetDirtyForInvalidation(std::set< PRUint32 > &aDirty)