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