/simpletypesystem/trunk

To get this branch, use:
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
S_BEGIN_DECLS
110 by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub.
17
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
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
S_EXPORTED
119 by Gustav Hartvigsson
* added S_EXPERTED to public functions.
45
SStream *
76 by Gustav Hartvigsson
* Started working on this thing...
46
s_stream_new ();
47
48
/**
49
 *
77 by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-)
50
 */
51
S_EXPORTED
119 by Gustav Hartvigsson
* added S_EXPERTED to public functions.
52
size_t
77 by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-)
53
s_stream_get_beffered (SStream * self);
54
55
/**
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
56
 * Read from the stream.
57
 *
58
 * Reading is thread safe as only one thread can preform a read or write at a
59
 * time.
60
 *
61
 * @param self The Stream to read from.
62
 * @param len The number of items to read.
63
 *
64
 * @returns An array with the bytes.
65
 *
66
 * @warning If the requested length is not available the rest will be
67
 *          zeroed out in the output.
68
 */
69
S_EXPORTED
119 by Gustav Hartvigsson
* added S_EXPERTED to public functions.
70
sbyte *
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
71
s_stream_read (SStream * self,
99 by Gustav Hartvigsson
* Working on RingBuffer and Stream.
72
               size_t len);
73
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
74
75
/**
76
 * Write data to a stream.
77
 *
78
 * Writing to the stream is thread safe as only one thread can perform a read
79
 * or a write to a stream at a time.
80
 *
81
 * @param self The stream to write to.
82
 * @param len The number of items to write to the stream.
83
 * @param data The bytes to be put in the stream.
84
 */
85
S_EXPORTED
119 by Gustav Hartvigsson
* added S_EXPERTED to public functions.
86
void
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
87
s_stream_write (SStream * self,
99 by Gustav Hartvigsson
* Working on RingBuffer and Stream.
88
                size_t len,
89
                sbyte * data);
90
77 by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-)
91
/**
92
 * @}
76 by Gustav Hartvigsson
* Started working on this thing...
93
 */
94
95
S_END_DECLS
110 by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub.
96
98 by Gustav Hartvigsson
* Started work on SRingBuffer to be used in SStream.
97
#endif /* __H_STREAM__ */
76 by Gustav Hartvigsson
* Started working on this thing...
98