sbLibraryConstraints.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-2008 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 __SB_LIBRARY_CONSTRAINTS_H__
28 #define __SB_LIBRARY_CONSTRAINTS_H__
29 
30 #include <sbILibraryConstraints.h>
31 
32 #include <nsAutoPtr.h>
33 #include <nsClassHashtable.h>
34 #include <nsCOMPtr.h>
35 #include <nsStringGlue.h>
36 #include <nsTArray.h>
37 #include <nsIClassInfo.h>
38 #include <nsISerializable.h>
39 
42 typedef nsTArray<nsString> sbStringArray;
43 typedef nsClassHashtable<nsStringHashKey, sbStringArray> sbConstraintGroup;
44 typedef nsRefPtr<sbLibraryConstraintGroup> sbConstraintGroupRefPtr;
45 typedef nsTArray<sbConstraintGroupRefPtr> sbConstraintArray;
46 
48 {
49 public:
51  NS_DECL_SBILIBRARYCONSTRAINTBUILDER
52 
53  nsresult Init();
54 private:
55  nsresult EnsureConstraint();
56  nsRefPtr<sbLibraryConstraint> mConstraint;
57 };
58 
60  public nsISerializable,
61  public nsIClassInfo
62 {
64 public:
66  NS_DECL_SBILIBRARYCONSTRAINT
67  NS_DECL_NSISERIALIZABLE
68  NS_DECL_NSICLASSINFO
69 
71 
72 private:
73  nsresult Init();
74  nsresult Intersect();
75  nsresult AddToCurrent(const nsAString& aProperty, sbStringArray* aArray);
76  PRBool IsValid();
77 
78  PRBool mInitialized;
79  sbConstraintArray mConstraint;
80 };
81 
83 {
84 friend class sbLibraryConstraint;
86 public:
88  NS_DECL_SBILIBRARYCONSTRAINTGROUP
89 
91 
92 private:
93  nsresult Init();
94  PRBool IsEmpty();
95  nsresult Add(const nsAString& aProperty, sbStringArray* aArray);
96  nsresult Read(nsIObjectInputStream* aStream);
97  nsresult Write(nsIObjectOutputStream* aStream);
98 
99  static PLDHashOperator PR_CALLBACK
100  AddKeysToArrayCallback(nsStringHashKey::KeyType aKey,
101  sbStringArray* aEntry,
102  void* aUserData);
103 
104  PRBool mInitialized;
105  sbConstraintGroup mConstraintGroup;
106 };
107 
109  public nsISerializable,
110  public nsIClassInfo
111 {
112 public:
114  NS_DECL_SBILIBRARYSORT
115  NS_DECL_NSISERIALIZABLE
116  NS_DECL_NSICLASSINFO
117 
118  sbLibrarySort();
119 
120 private:
121  PRBool mInitialized;
122  nsString mProperty;
123  PRBool mIsAscending;
124 };
125 
126 #endif /* __SB_LIBRARY_CONSTRAINTS_H__ */
127 
NS_DECL_ISUPPORTS NS_DECL_SBILIBRARYCONSTRAINT NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO sbLibraryConstraint()
nsTArray< sbConstraintGroupRefPtr > sbConstraintArray
nsClassHashtable< nsStringHashKey, sbStringArray > sbConstraintGroup
nsTArray< nsString > sbStringArray
nsRefPtr< sbLibraryConstraintGroup > sbConstraintGroupRefPtr
NS_DECL_ISUPPORTS NS_DECL_SBILIBRARYSORT NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO sbLibrarySort()
nsTArray< nsString > sbStringArray
NS_DECL_ISUPPORTS NS_DECL_SBILIBRARYCONSTRAINTGROUP sbLibraryConstraintGroup()
nsISerializable
A sort that can be applied to a media list view.
NS_DECL_ISUPPORTS NS_DECL_SBILIBRARYCONSTRAINTBUILDER nsresult Init()