2 * Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
14 #include "PackageFile.h"
17 using namespace BPackageKit
;
22 Package(PackageFile
* file
);
25 PackageFile
* File() const
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(); }
45 void SetActive(bool active
)
48 Package
* Clone() const;
50 Package
*& FileNameHashTableNext()
51 { return fFileNameHashTableNext
; }
52 Package
*& NodeRefHashTableNext()
53 { return fNodeRefHashTableNext
; }
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
;