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
18class Resource : public Object {
19private:
20	BString	 fTransport;
21	BString  fTransportAddress;
22	BString  fConnection;
23	sem_id   fResourceAvailable;
24
25public:
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
39class ResourceManager {
40private:
41	BObjectList<Resource> fResources;
42
43	Resource* Find(const char* transport, const char* address, const char* connection);
44
45public:
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