25 #ifndef __SBLOCALDATABASEGUIDARRAY_H__
26 #define __SBLOCALDATABASEGUIDARRAY_H__
28 #include "sbILocalDatabaseGUIDArray.h"
29 #include "sbILocalDatabasePropertyCache.h"
32 #include <nsAutoPtr.h>
34 #include <nsDataHashtable.h>
35 #include <nsStringGlue.h>
37 #include <sbIDatabaseQuery.h>
38 #include <sbISQLBuilder.h>
39 #include <nsISimpleEnumerator.h>
40 #include <nsIStringEnumerator.h>
41 #include <sbIDatabasePreparedStatement.h>
42 #include <sbILocalDatabaseLibrary.h>
43 #include <sbIMediaItem.h>
51 class nsIWeakReference;
61 NS_DECL_SBILOCALDATABASEGUIDARRAY
81 ArrayItem(
const ArrayItem& aOther) :
82 mediaItemId(aOther.mediaItemId),
84 sortPropertyValue(aOther.sortPropertyValue),
85 ordinal(aOther.ordinal),
88 MOZ_COUNT_CTOR(ArrayItem);
91 ArrayItem(PRUint32 aMediaItemId,
92 const nsAString& aGuid,
94 const nsAString& aOrdinal,
96 mediaItemId(aMediaItemId),
98 sortPropertyValue(aValue),
102 MOZ_COUNT_CTOR(ArrayItem);
105 ArrayItem(PRUint32 aMediaItemId,
106 const PRUnichar* aGuid,
108 const PRUnichar* aOrdinal,
110 mediaItemId(aMediaItemId),
112 sortPropertyValue(aValue),
116 MOZ_COUNT_CTOR(ArrayItem);
121 MOZ_COUNT_DTOR(ArrayItem);
124 PRUint32 mediaItemId;
126 nsString sortPropertyValue;
131 ~sbLocalDatabaseGUIDArray();
133 nsresult Initialize();
135 nsresult UpdateLength();
140 nsresult UpdateQueries();
142 nsresult GetPrimarySortKeyPosition(
const nsAString&
aValue,
148 nsresult FetchRows(PRUint32 aRequestedIndex, PRUint32 aFetchSize);
150 nsresult SortRows(PRUint32 aStartIndex,
152 const nsAString& aKey,
159 PRUint32 aStartIndex,
161 PRUint32 aDestIndexOffset,
164 nsresult GetByIndexInternal(PRUint32 aIndex, ArrayItem** _retval);
166 PRInt32 GetPropertyId(
const nsAString& aProperty);
168 static int SortBags(
const void* a,
const void* b,
void* closure);
170 nsresult AddSortInternal(
const nsAString& aProperty,
173 nsresult ClearSecondarySorts();
177 void QueryInvalidate() {
178 mQueriesValid = PR_FALSE;
182 void GenerateCachedLengthKey();
183 PRPackedBool mNeedNewKey;
184 nsString mCachedLengthKey;
186 nsCOMPtr<sbILocalDatabaseGUIDArrayLengthCache> mLengthCache;
190 std::set<PRUint32> mPropIdsUsedInCacheKey;
191 PRLock* mPropIdsLock;
194 nsCOMPtr<sbIPropertyManager> mPropMan;
197 nsString mDatabaseGUID;
200 nsCOMPtr<nsIURI> mDatabaseLocation;
206 nsString mBaseConstraintColumn;
209 PRUint32 mBaseConstraintValue;
218 PRUint32 mNonNullLength;
221 nsTArray<SortSpec> mSorts;
224 PRInt32 mPrimarySortsCount;
227 nsTArray<FilterSpec> mFilters;
230 PRMonitor* mCacheMonitor;
232 nsTArray<nsAutoPtr<ArrayItem> > mCache;
235 nsDataHashtable<nsStringHashKey, PRUint32> mPrimarySortKeyPositionCache;
238 nsString mFullCountQuery;
239 nsCOMPtr<sbIDatabasePreparedStatement> mFullCountStatement;
243 nsString mNonNullCountQuery;
244 nsCOMPtr<sbIDatabasePreparedStatement> mNonNullCountStatement;
247 nsString mFullGuidRangeQuery;
248 nsCOMPtr<sbIDatabasePreparedStatement> mFullGuidRangeStatement;
251 nsString mNullGuidRangeQuery;
252 nsCOMPtr<sbIDatabasePreparedStatement> mNullGuidRangeStatement;
255 nsString mResortQuery;
256 nsCOMPtr<sbIDatabasePreparedStatement> mResortStatement;
259 nsString mNullResortQuery;
260 nsCOMPtr<sbIDatabasePreparedStatement> mNullResortStatement;
263 nsString mPrefixSearchQuery;
264 nsCOMPtr<sbIDatabasePreparedStatement> mPrefixSearchStatement;
268 nsString mPrimarySortKeyPositionQuery;
269 nsCOMPtr<sbIDatabasePreparedStatement> mPrimarySortKeyPositionStatement;
272 nsCOMPtr<sbIDatabasePreparedStatement> mStatementX;
273 nsCOMPtr<sbIDatabasePreparedStatement> mStatementY;
277 nsCOMPtr<nsIWeakReference> mListener;
280 nsCOMPtr<sbILocalDatabasePropertyCache> mPropertyCache;
283 nsDataHashtable<nsStringHashKey, PRUint32> mGuidToFirstIndexMap;
286 nsDataHashtable<nsStringHashKey, PRUint32> mViewItemUIDToIndexMap;
289 PRPackedBool mIsDistinct;
291 PRPackedBool mDistinctWithSortableValues;
297 PRPackedBool mQueriesValid;
300 PRPackedBool mHasActiveSearch;
303 PRPackedBool mNullsFirst;
306 PRPackedBool mPrefetchedRows;
309 PRPackedBool mIsFullLibrary;
319 NS_DECL_NSISIMPLEENUMERATOR
327 nsRefPtr<sbLocalDatabaseLibrary> mLibrary;
328 nsCOMPtr<sbILocalDatabaseGUIDArray> mArray;
333 PRUint32 mPreviousLength;
340 NS_DECL_NSISTRINGENUMERATOR
347 nsCOMPtr<sbILocalDatabaseGUIDArray> mArray;
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR sbGUIDArrayEnumerator(sbLocalDatabaseLibrary *aLibrary, sbILocalDatabaseGUIDArray *aArray)
NS_DECL_ISUPPORTS NS_DECL_SBILOCALDATABASEGUIDARRAY sbLocalDatabaseGUIDArray()
Media library abstraction.
nsTArray< nsString > values
An object responsible for executing SQL queries on the database.
restoreHistoryPrecursor aCount
~sbGUIDArrayStringEnumerator()
Manager for system wide metadata properties.
NS_DECL_ISUPPORTS NS_DECL_NSISTRINGENUMERATOR sbGUIDArrayStringEnumerator(sbILocalDatabaseGUIDArray *aArray)
A prepared database statement.