bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
76
by Gustav Hartvigsson
* Started working on this thing... |
1 |
#ifndef __H_STREAM__
|
2 |
#define __H_STREAM__
|
|
3 |
||
4 |
#include "baseobject.h" |
|
5 |
#include "defs.h" |
|
6 |
#include "utils.h" |
|
7 |
||
8 |
/**
|
|
9 |
* @defgroup SStream SStream
|
|
10 |
* @addtogroup SStream
|
|
11 |
* @{
|
|
12 |
* @warning unimplemented.
|
|
13 |
* @TODO
|
|
14 |
*/
|
|
15 |
||
16 |
BEGIN_DECLS
|
|
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
17 |
|
18 |
#define S_STREAM(o) ((SStream *)(o))
|
|
19 |
#define S_STREAM_CLASS(c) ((SStreamClass *)(c))
|
|
|
99
by Gustav Hartvigsson
* Working on RingBuffer and Stream. |
20 |
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
21 |
typedef struct SStream SStream; |
22 |
typedef struct SStreamClass SStreamClass; |
|
23 |
typedef struct SStreamPrivate SStreamPrivate; |
|
24 |
||
25 |
||
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
26 |
typedef sbyte * (*StreamReader)(SStream * self, size_t len); |
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
27 |
typedef void (*StreamWriter)(SStream * self, size_t len, sbyte * data); |
28 |
||
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
29 |
struct SStream { |
|
76
by Gustav Hartvigsson
* Started working on this thing... |
30 |
SObject parent; |
31 |
SStreamPrivate * priv; |
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
32 |
};
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
33 |
|
34 |
struct SStreamClass { |
|
35 |
SObjectClass parent_class; |
|
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
36 |
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
37 |
StreamReader reader; |
38 |
StreamWriter writer; |
|
39 |
};
|
|
40 |
||
41 |
/**
|
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
42 |
* Create a new stream.
|
43 |
*/
|
|
44 |
SStream * |
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
45 |
s_stream_new (); |
46 |
||
47 |
/**
|
|
48 |
*
|
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
49 |
*/
|
50 |
size_t
|
|
51 |
s_stream_get_beffered (SStream * self); |
|
52 |
||
53 |
/**
|
|
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
54 |
* Read from the stream.
|
55 |
*
|
|
56 |
* Reading is thread safe as only one thread can preform a read or write at a
|
|
57 |
* time.
|
|
58 |
*
|
|
59 |
* @param self The Stream to read from.
|
|
60 |
* @param len The number of items to read.
|
|
61 |
*
|
|
62 |
* @returns An array with the bytes.
|
|
63 |
*
|
|
64 |
* @warning If the requested length is not available the rest will be
|
|
65 |
* zeroed out in the output.
|
|
66 |
*/
|
|
67 |
sbyte * |
|
68 |
s_stream_read (SStream * self, |
|
|
99
by Gustav Hartvigsson
* Working on RingBuffer and Stream. |
69 |
size_t len); |
70 |
||
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
71 |
|
72 |
/**
|
|
73 |
* Write data to a stream.
|
|
74 |
*
|
|
75 |
* Writing to the stream is thread safe as only one thread can perform a read
|
|
76 |
* or a write to a stream at a time.
|
|
77 |
*
|
|
78 |
* @param self The stream to write to.
|
|
79 |
* @param len The number of items to write to the stream.
|
|
80 |
* @param data The bytes to be put in the stream.
|
|
81 |
*/
|
|
82 |
void
|
|
83 |
s_stream_write (SStream * self, |
|
|
99
by Gustav Hartvigsson
* Working on RingBuffer and Stream. |
84 |
size_t len, |
85 |
sbyte * data); |
|
86 |
||
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
87 |
/**
|
88 |
* @}
|
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
89 |
*/
|
90 |
||
91 |
END_DECLS
|
|
|
98
by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream. |
92 |
|
93 |
#endif /* __H_STREAM__ */ |
|
|
76
by Gustav Hartvigsson
* Started working on this thing... |
94 |