[5554] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[5524] | 3 | |
---|
[5554] | 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 */ |
---|
[5562] | 17 | #include "data_stream.h" |
---|
[5524] | 18 | |
---|
[5554] | 19 | |
---|
| 20 | |
---|
[5562] | 21 | |
---|
[5554] | 22 | /* using namespace std is default, this needs to be here */ |
---|
| 23 | using namespace std; |
---|
| 24 | |
---|
[5649] | 25 | |
---|
| 26 | |
---|
[5611] | 27 | /** |
---|
| 28 | * This is the empty construktor |
---|
| 29 | */ |
---|
[5649] | 30 | DataStream::DataStream() |
---|
| 31 | { |
---|
| 32 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | /** |
---|
| 38 | * This is the empty construktor |
---|
| 39 | */ |
---|
[5648] | 40 | DataStream::DataStream(Synchronizeable& sync) |
---|
[5611] | 41 | { |
---|
[5648] | 42 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
[5649] | 43 | this->synchronizeable = &sync; |
---|
[5611] | 44 | |
---|
| 45 | } |
---|
[5554] | 46 | |
---|
| 47 | /** |
---|
[5562] | 48 | * This constructor creates a new DataStream and connects it to both streams (upStream, downStream) |
---|
[5554] | 49 | */ |
---|
[5611] | 50 | DataStream::DataStream(DataStream& inStream, DataStream& outStream) |
---|
[5569] | 51 | { |
---|
[5600] | 52 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
[5719] | 53 | this->downStream = &outStream; |
---|
| 54 | this->upStream = &inStream; |
---|
[5554] | 55 | } |
---|
| 56 | |
---|
| 57 | /** |
---|
[5562] | 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 | { |
---|
[5600] | 62 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
[5719] | 63 | this->networkSocket = &socket; |
---|
[5600] | 64 | } |
---|
[5569] | 65 | |
---|
[5600] | 66 | /** |
---|
| 67 | * This constructor creates a new DataStream and connects the Synchronizeable to it |
---|
| 68 | */ |
---|
[5611] | 69 | DataStream::DataStream(Synchronizeable& sync, DataStream& outStream) |
---|
[5600] | 70 | { |
---|
| 71 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
[5719] | 72 | this->downStream = &outStream; |
---|
[5562] | 73 | } |
---|
| 74 | |
---|
| 75 | /** |
---|
[5600] | 76 | * This constructor creates a new DataStream and connects the NetworkSocket to it |
---|
| 77 | */ |
---|
[5611] | 78 | DataStream::DataStream(DataStream& inStream, NetworkSocket& socket) |
---|
[5600] | 79 | { |
---|
| 80 | this->setClassID(CL_DATA_STREAM, "DataStream"); |
---|
[5719] | 81 | this->upStream = &inStream; |
---|
| 82 | this->networkSocket = &socket; |
---|
[5600] | 83 | } |
---|
| 84 | |
---|
| 85 | /** |
---|
[5554] | 86 | * standart deconstructor |
---|
| 87 | */ |
---|
[5562] | 88 | DataStream::~DataStream() |
---|
[5524] | 89 | { |
---|
[5569] | 90 | |
---|
[5524] | 91 | } |
---|
| 92 | |
---|
[5554] | 93 | /** |
---|
[5611] | 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 | /** |
---|
[5569] | 126 | * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning |
---|
[5562] | 127 | * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this |
---|
| 128 | * Stream |
---|
[5554] | 129 | */ |
---|
[5562] | 130 | void DataStream::connectUpStream(DataStream& upStream) |
---|
[5524] | 131 | { |
---|
[5569] | 132 | |
---|
[5554] | 133 | } |
---|
| 134 | |
---|
[5562] | 135 | /** |
---|
[5569] | 136 | * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning |
---|
[5562] | 137 | * that the stream is "closer" to the NetworkSocket. |
---|
| 138 | */ |
---|
| 139 | void DataStream::connectDownStream(DataStream& upStream) |
---|
| 140 | { |
---|
[5569] | 141 | |
---|
[5562] | 142 | } |
---|
[5554] | 143 | |
---|
| 144 | /** |
---|
[5562] | 145 | * This function disconnects the upStream and sets it to NULL |
---|
[5554] | 146 | */ |
---|
[5562] | 147 | void DataStream::disconnectUpStream() |
---|
[5554] | 148 | { |
---|
[5569] | 149 | |
---|
[5524] | 150 | } |
---|
| 151 | |
---|
[5562] | 152 | /** |
---|
| 153 | * This function disconnects the downStream and sets it to NULL |
---|
| 154 | */ |
---|
| 155 | void DataStream::disconnectDownStream() |
---|
| 156 | { |
---|
[5569] | 157 | |
---|
[5562] | 158 | } |
---|
[5554] | 159 | |
---|
[5569] | 160 | |
---|
[5600] | 161 | /** |
---|
| 162 | * Following functions are protected and only visible inside the object and from derived classes |
---|
| 163 | */ |
---|
[5554] | 164 | |
---|
| 165 | /** |
---|
[5562] | 166 | * This function writes the binary data to the local data. You will have to copy each byte and not only dublicate |
---|
| 167 | * it. |
---|
[5719] | 168 | * |
---|
| 169 | * @param data: the binary array |
---|
| 170 | * @param length: the length of the array |
---|
[5554] | 171 | */ |
---|
[5719] | 172 | void passDown(byte* data, int length) |
---|
[5524] | 173 | { |
---|
[5719] | 174 | |
---|
[5524] | 175 | } |
---|
| 176 | |
---|
[5554] | 177 | |
---|
| 178 | /** |
---|
[5562] | 179 | * This function returns a reference to the local upData data array. So it can be read by an upper Stream |
---|
| 180 | * The reading function will have to copy the whole data and musn't just reference it! |
---|
| 181 | * This function is only called from other connected DataStreams to read the data. |
---|
[5719] | 182 | * |
---|
| 183 | * @param data: the binary array |
---|
| 184 | * @return: the length of the data |
---|
[5554] | 185 | */ |
---|
[5719] | 186 | int passUp(byte* data) |
---|
[5524] | 187 | { |
---|
[5719] | 188 | |
---|
[5524] | 189 | } |
---|