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 15class VolumeState { 16public: 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 39private: 40 void _RemovePackage(Package* package); 41 42private: 43 PackageFileNameHashTable fPackagesByFileName; 44 PackageNodeRefHashTable fPackagesByNodeRef; 45}; 46 47 48inline Package* 49VolumeState::FindPackage(const char* name) const 50{ 51 return fPackagesByFileName.Lookup(name); 52} 53 54 55inline Package* 56VolumeState::FindPackage(const node_ref& nodeRef) const 57{ 58 return fPackagesByNodeRef.Lookup(nodeRef); 59} 60 61 62inline PackageFileNameHashTable::Iterator 63VolumeState::ByFileNameIterator() const 64{ 65 return fPackagesByFileName.GetIterator(); 66} 67 68 69inline PackageNodeRefHashTable::Iterator 70VolumeState::ByNodeRefIterator() const 71{ 72 return fPackagesByNodeRef.GetIterator(); 73} 74 75 76#endif // VOLUME_STATE_H 77