xref: /haiku/src/servers/print/ResourceManager.h (revision 93a78ecaa45114d68952d08c4778f073515102f2)
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 	bool NeedsLocking();
26 
27 
28 public:
29 	Resource(const char* transport, const char* address, const char* connection);
30 	~Resource();
31 
32 	bool Equals(const char* transport, const char* address, const char* connection);
33 
34 	const BString& Transport() const { return fTransport; }
35 
36 	bool Lock();
37 	void Unlock();
38 };
39 
40 class ResourceManager {
41 private:
42 	BObjectList<Resource> fResources;
43 
44 	Resource* Find(const char* transport, const char* address, const char* connection);
45 
46 public:
47 	~ResourceManager();
48 
49 	Resource* Allocate(const char* transport, const char* address, const char* connection);
50 	void Free(Resource* r);
51 };
52 
53 #endif
54