xref: /haiku/headers/private/userlandfs/private/Port.h (revision b19ee1e164ffad53dff3600cdac7e9781c636581)
1 /*
2  * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef USERLAND_FS_PORT_H
6 #define USERLAND_FS_PORT_H
7 
8 #include <OS.h>
9 
10 class KernelDebug;
11 
12 namespace UserlandFSUtil {
13 
14 struct PortInfo {
15 };
16 
17 class Port {
18 public:
19 			struct Info {
20 				port_id			owner_port;
21 				port_id			client_port;
22 				int32			size;
23 			};
24 
25 public:
26 								Port(int32 size);
27 								Port(const Info* info);
28 								~Port();
29 
30 			void				Close();
31 
32 			status_t			InitCheck() const;
33 
34 			const Info*			GetInfo() const;
35 
GetBuffer()36 			void*				GetBuffer() const	{ return fBuffer; }
GetCapacity()37 			int32				GetCapacity() const	{ return fCapacity; }
38 
39 			void				Reserve(int32 endOffset);
40 			void				Unreserve(int32 endOffset);
ReservedSize()41 			int32				ReservedSize() const { return fReservedSize; }
42 
43 			status_t			Send(const void* message, int32 size);
44 			status_t			Receive(void** _message, size_t* _size,
45 									bigtime_t timeout = -1);
46 
47 private:
48 			friend class ::KernelDebug;
49 
50 			Info				fInfo;
51 			uint8*				fBuffer;
52 			int32				fCapacity;
53 			int32				fReservedSize;
54 			status_t			fInitStatus;
55 			bool				fOwner;
56 };
57 
58 }	// namespace UserlandFSUtil
59 
60 using UserlandFSUtil::PortInfo;
61 using UserlandFSUtil::Port;
62 
63 #endif	// USERLAND_FS_PORT_H
64