xref: /haiku/src/servers/print/ResourceManager.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2002-2006, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Pfeiffer
7  */
8 #ifndef RESOURCE_MANAGER_H
9 #define RESOURCE_MANAGER_H
10 
11 #include "ObjectList.h"
12 
13 #include <Locker.h>
14 #include <String.h>
15 
16 #include "BeUtils.h"
17 
18 class Resource : public Object {
19 private:
20 	BString	 fTransport;
21 	BString  fTransportAddress;
22 	BString  fConnection;
23 	sem_id   fResourceAvailable;
24 
25 public:
26 	Resource(const char* transport, const char* address, const char* connection);
27 	~Resource();
28 
29 	bool NeedsLocking();
30 
31 	bool Equals(const char* transport, const char* address, const char* connection);
32 
33 	const BString& Transport() const { return fTransport; }
34 
35 	bool Lock();
36 	void Unlock();
37 };
38 
39 class ResourceManager {
40 private:
41 	BObjectList<Resource> fResources;
42 
43 	Resource* Find(const char* transport, const char* address, const char* connection);
44 
45 public:
46 	~ResourceManager();
47 
48 	Resource* Allocate(const char* transport, const char* address, const char* connection);
49 	void Free(Resource* r);
50 };
51 
52 #endif
53