1/*
2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef PACKAGE_DOMAIN_H
6#define PACKAGE_DOMAIN_H
7
8
9#include <Referenceable.h>
10
11#include <util/DoublyLinkedList.h>
12
13#include "Package.h"
14
15
16class NotificationListener;
17class Volume;
18
19
20class PackageDomain : public BReferenceable,
21	public DoublyLinkedListLinkImpl<PackageDomain> {
22public:
23								PackageDomain(::Volume* volume);
24								~PackageDomain();
25
26			::Volume*			Volume() const	{ return fVolume; }
27			const char*			Path() const	{ return fPath; }
28			int					DirectoryFD()	{ return fDirFD; }
29			dev_t				DeviceID()		{ return fDeviceID; }
30			ino_t				NodeID()		{ return fNodeID; }
31
32			status_t			Init(const char* path);
33			status_t			Prepare(NotificationListener* listener);
34									// takes over ownership of the listener
35
36			void				AddPackage(Package* package);
37			void				RemovePackage(Package* package);
38
39			Package*			FindPackage(const char* fileName) const;
40
41			const PackageFileNameHashTable& Packages() const
42									{ return fPackages; }
43
44private:
45			::Volume*			fVolume;
46			char*				fPath;
47			int					fDirFD;
48			dev_t				fDeviceID;
49			ino_t				fNodeID;
50			NotificationListener* fListener;
51			PackageFileNameHashTable fPackages;
52};
53
54
55#endif	// PACKAGE_DOMAIN_H
56