btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / package / Package.h
blobd89d3e89a116d02b287217c10163b9044e002794
1 /*
2 * Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
7 */
8 #ifndef PACKAGE_H
9 #define PACKAGE_H
12 #include <set>
14 #include "PackageFile.h"
17 using namespace BPackageKit;
20 class Package {
21 public:
22 Package(PackageFile* file);
23 ~Package();
25 PackageFile* File() const
26 { return fFile; }
28 const node_ref& NodeRef() const
29 { return fFile->NodeRef(); }
30 const BString& FileName() const
31 { return fFile->FileName(); }
32 NotOwningEntryRef EntryRef() const
33 { return fFile->EntryRef(); }
35 const BPackageInfo & Info() const
36 { return fFile->Info(); }
38 BString RevisionedName() const
39 { return fFile->RevisionedName(); }
40 BString RevisionedNameThrows() const
41 { return fFile->RevisionedNameThrows(); }
43 bool IsActive() const
44 { return fActive; }
45 void SetActive(bool active)
46 { fActive = active; }
48 Package* Clone() const;
50 Package*& FileNameHashTableNext()
51 { return fFileNameHashTableNext; }
52 Package*& NodeRefHashTableNext()
53 { return fNodeRefHashTableNext; }
55 private:
56 PackageFile* fFile;
57 bool fActive;
58 Package* fFileNameHashTableNext;
59 Package* fNodeRefHashTableNext;
63 struct PackageFileNameHashDefinition {
64 typedef const char* KeyType;
65 typedef Package ValueType;
67 size_t HashKey(const char* key) const
69 return BString::HashValue(key);
72 size_t Hash(const Package* value) const
74 return HashKey(value->FileName());
77 bool Compare(const char* key, const Package* value) const
79 return value->FileName() == key;
82 Package*& GetLink(Package* value) const
84 return value->FileNameHashTableNext();
89 struct PackageNodeRefHashDefinition {
90 typedef node_ref KeyType;
91 typedef Package ValueType;
93 size_t HashKey(const node_ref& key) const
95 return (size_t)key.device + 17 * (size_t)key.node;
98 size_t Hash(const Package* value) const
100 return HashKey(value->NodeRef());
103 bool Compare(const node_ref& key, const Package* value) const
105 return key == value->NodeRef();
108 Package*& GetLink(Package* value) const
110 return value->NodeRefHashTableNext();
115 typedef BOpenHashTable<PackageFileNameHashDefinition> PackageFileNameHashTable;
116 typedef BOpenHashTable<PackageNodeRefHashDefinition> PackageNodeRefHashTable;
117 typedef std::set<Package*> PackageSet;
120 #endif // PACKAGE_H