1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Knecht |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | /* include Data_stream Header */ |
---|
17 | #include "data_stream.h" |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | /* using namespace std is default, this needs to be here */ |
---|
23 | using namespace std; |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | /** |
---|
28 | * This is the empty construktor |
---|
29 | */ |
---|
30 | DataStream::DataStream() |
---|
31 | { |
---|
32 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | /** |
---|
38 | * This is the empty construktor |
---|
39 | */ |
---|
40 | DataStream::DataStream(Synchronizeable& sync) |
---|
41 | { |
---|
42 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
43 | this->synchronizeable = &sync; |
---|
44 | |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * This constructor creates a new DataStream and connects it to both streams (upStream, downStream) |
---|
49 | */ |
---|
50 | DataStream::DataStream(DataStream& inStream, DataStream& outStream) |
---|
51 | { |
---|
52 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
53 | downStream = &outStream; |
---|
54 | upStream = &inStream; |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * This constructor creates a new DataStream and connects it to a synchronizeable object and the NetworkSocket |
---|
59 | */ |
---|
60 | DataStream::DataStream(Synchronizeable& sync, NetworkSocket& socket) |
---|
61 | { |
---|
62 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
63 | networkSocket = &socket; |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * This constructor creates a new DataStream and connects the Synchronizeable to it |
---|
68 | */ |
---|
69 | DataStream::DataStream(Synchronizeable& sync, DataStream& outStream) |
---|
70 | { |
---|
71 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
72 | downStream = &outStream; |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * This constructor creates a new DataStream and connects the NetworkSocket to it |
---|
77 | */ |
---|
78 | DataStream::DataStream(DataStream& inStream, NetworkSocket& socket) |
---|
79 | { |
---|
80 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
81 | upStream = &inStream; |
---|
82 | networkSocket = &socket; |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * standart deconstructor |
---|
87 | */ |
---|
88 | DataStream::~DataStream() |
---|
89 | { |
---|
90 | |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * This funtion connects this stream to a Synchronizable object. This stream is the top of the stream-chain. |
---|
95 | */ |
---|
96 | void DataStream::connectSynchronizeable(Synchronizeable& sync) |
---|
97 | { |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | /** |
---|
102 | * And this function disconnects the Synch-object and sets it to NULL |
---|
103 | */ |
---|
104 | void DataStream::disconnectSynchronizeable() |
---|
105 | { |
---|
106 | |
---|
107 | } |
---|
108 | |
---|
109 | /** |
---|
110 | * This function connects the stream to a NetworkSocket. This stream is the bottom of the stream-chain |
---|
111 | */ |
---|
112 | void DataStream::connectNetworkSocket(NetworkSocket& socket) |
---|
113 | { |
---|
114 | |
---|
115 | } |
---|
116 | |
---|
117 | /** |
---|
118 | * And this function disconnects the Socket and sets it to NULL |
---|
119 | */ |
---|
120 | void DataStream::disconnectNetworkSocket() |
---|
121 | { |
---|
122 | |
---|
123 | } |
---|
124 | |
---|
125 | /** |
---|
126 | * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning |
---|
127 | * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this |
---|
128 | * Stream |
---|
129 | */ |
---|
130 | void DataStream::connectUpStream(DataStream& upStream) |
---|
131 | { |
---|
132 | |
---|
133 | } |
---|
134 | |
---|
135 | /** |
---|
136 | * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning |
---|
137 | * that the stream is "closer" to the NetworkSocket. |
---|
138 | */ |
---|
139 | void DataStream::connectDownStream(DataStream& upStream) |
---|
140 | { |
---|
141 | |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * This function disconnects the upStream and sets it to NULL |
---|
146 | */ |
---|
147 | void DataStream::disconnectUpStream() |
---|
148 | { |
---|
149 | |
---|
150 | } |
---|
151 | |
---|
152 | /** |
---|
153 | * This function disconnects the downStream and sets it to NULL |
---|
154 | */ |
---|
155 | void DataStream::disconnectDownStream() |
---|
156 | { |
---|
157 | |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | /** |
---|
162 | * Following functions are protected and only visible inside the object and from derived classes |
---|
163 | */ |
---|
164 | |
---|
165 | /** |
---|
166 | * This function writes the binary data to the local data. You will have to copy each byte and not only dublicate |
---|
167 | * it. |
---|
168 | */ |
---|
169 | void DataStream::writeBytes(byte& data) |
---|
170 | { |
---|
171 | |
---|
172 | } |
---|
173 | |
---|
174 | |
---|
175 | /** |
---|
176 | * This function returns a reference to the local upData data array. So it can be read by an upper Stream |
---|
177 | * The reading function will have to copy the whole data and musn't just reference it! |
---|
178 | * This function is only called from other connected DataStreams to read the data. |
---|
179 | */ |
---|
180 | byte& DataStream::readBytes() |
---|
181 | { |
---|
182 | |
---|
183 | } |
---|