1 /* 2 * Copyright 2013-2014, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 */ 8 #ifndef VOLUME_STATE_H 9 #define VOLUME_STATE_H 10 11 12 #include "Package.h" 13 14 15 class VolumeState { 16 public: 17 VolumeState(); 18 ~VolumeState(); 19 20 bool Init(); 21 22 Package* FindPackage(const char* name) const; 23 Package* FindPackage(const node_ref& nodeRef) const; 24 25 PackageFileNameHashTable::Iterator ByFileNameIterator() const; 26 PackageNodeRefHashTable::Iterator ByNodeRefIterator() const; 27 28 void AddPackage(Package* package); 29 void RemovePackage(Package* package); 30 31 void SetPackageActive(Package* package, bool active); 32 33 void ActivationChanged( 34 const PackageSet& activatedPackage, 35 const PackageSet& deactivatePackages); 36 37 VolumeState* Clone() const; 38 39 private: 40 void _RemovePackage(Package* package); 41 42 private: 43 PackageFileNameHashTable fPackagesByFileName; 44 PackageNodeRefHashTable fPackagesByNodeRef; 45 }; 46 47 48 inline Package* 49 VolumeState::FindPackage(const char* name) const 50 { 51 return fPackagesByFileName.Lookup(name); 52 } 53 54 55 inline Package* 56 VolumeState::FindPackage(const node_ref& nodeRef) const 57 { 58 return fPackagesByNodeRef.Lookup(nodeRef); 59 } 60 61 62 inline PackageFileNameHashTable::Iterator 63 VolumeState::ByFileNameIterator() const 64 { 65 return fPackagesByFileName.GetIterator(); 66 } 67 68 69 inline PackageNodeRefHashTable::Iterator 70 VolumeState::ByNodeRefIterator() const 71 { 72 return fPackagesByNodeRef.GetIterator(); 73 } 74 75 76 #endif // VOLUME_STATE_H 77