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 | * This is the empty construktor |
---|
27 | */ |
---|
28 | DataStream::DataStream() |
---|
29 | { |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * This constructor creates a new DataStream and connects it to both streams (upStream, downStream) |
---|
35 | */ |
---|
36 | DataStream::DataStream(DataStream& inStream, DataStream& outStream) |
---|
37 | { |
---|
38 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
39 | downStream = &outStream; |
---|
40 | upStream = &inStream; |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | * This constructor creates a new DataStream and connects it to a synchronizeable object and the NetworkSocket |
---|
45 | */ |
---|
46 | DataStream::DataStream(Synchronizeable& sync, NetworkSocket& socket) |
---|
47 | { |
---|
48 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
49 | nSocket = &socket; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * This constructor creates a new DataStream and connects the Synchronizeable to it |
---|
54 | */ |
---|
55 | DataStream::DataStream(Synchronizeable& sync, DataStream& outStream) |
---|
56 | { |
---|
57 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
58 | downStream = &outStream; |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * This constructor creates a new DataStream and connects the NetworkSocket to it |
---|
63 | */ |
---|
64 | DataStream::DataStream(DataStream& inStream, NetworkSocket& socket) |
---|
65 | { |
---|
66 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
67 | upStream = &inStream; |
---|
68 | nSocket = &socket; |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * standart deconstructor |
---|
73 | */ |
---|
74 | DataStream::~DataStream() |
---|
75 | { |
---|
76 | |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | * This funtion connects this stream to a Synchronizable object. This stream is the top of the stream-chain. |
---|
81 | */ |
---|
82 | void DataStream::connectSynchronizeable(Synchronizeable& sync) |
---|
83 | { |
---|
84 | |
---|
85 | } |
---|
86 | |
---|
87 | /** |
---|
88 | * And this function disconnects the Synch-object and sets it to NULL |
---|
89 | */ |
---|
90 | void DataStream::disconnectSynchronizeable() |
---|
91 | { |
---|
92 | |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * This function connects the stream to a NetworkSocket. This stream is the bottom of the stream-chain |
---|
97 | */ |
---|
98 | void DataStream::connectNetworkSocket(NetworkSocket& socket) |
---|
99 | { |
---|
100 | |
---|
101 | } |
---|
102 | |
---|
103 | /** |
---|
104 | * And this function disconnects the Socket and sets it to NULL |
---|
105 | */ |
---|
106 | void DataStream::disconnectNetworkSocket() |
---|
107 | { |
---|
108 | |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning |
---|
113 | * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this |
---|
114 | * Stream |
---|
115 | */ |
---|
116 | void DataStream::connectUpStream(DataStream& upStream) |
---|
117 | { |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning |
---|
123 | * that the stream is "closer" to the NetworkSocket. |
---|
124 | */ |
---|
125 | void DataStream::connectDownStream(DataStream& upStream) |
---|
126 | { |
---|
127 | |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * This function disconnects the upStream and sets it to NULL |
---|
132 | */ |
---|
133 | void DataStream::disconnectUpStream() |
---|
134 | { |
---|
135 | |
---|
136 | } |
---|
137 | |
---|
138 | /** |
---|
139 | * This function disconnects the downStream and sets it to NULL |
---|
140 | */ |
---|
141 | void DataStream::disconnectDownStream() |
---|
142 | { |
---|
143 | |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * This function moves the data from the downStream object to the upStream object and changes the data if necessary. |
---|
148 | * This function is virtual and therefore needs to be extended by the derived class |
---|
149 | */ |
---|
150 | void DataStream::processData() |
---|
151 | { |
---|
152 | |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | * Following functions are protected and only visible inside the object and from derived classes |
---|
157 | */ |
---|
158 | |
---|
159 | /** |
---|
160 | * This function writes the binary data to the local data. You will have to copy each byte and not only dublicate |
---|
161 | * it. |
---|
162 | */ |
---|
163 | void DataStream::writeBytes(byte& data) |
---|
164 | { |
---|
165 | |
---|
166 | } |
---|
167 | |
---|
168 | |
---|
169 | /** |
---|
170 | * This function returns a reference to the local upData data array. So it can be read by an upper Stream |
---|
171 | * The reading function will have to copy the whole data and musn't just reference it! |
---|
172 | * This function is only called from other connected DataStreams to read the data. |
---|
173 | */ |
---|
174 | byte& DataStream::readBytes() |
---|
175 | { |
---|
176 | |
---|
177 | } |
---|