| | 1 | = !DataStream = |
| | 2 | [[ArchivePage]] |
| | 3 | |
| | 4 | Short description of the module and its functions: |
| | 5 | |
| | 6 | Next Steps: |
| | 7 | * Create an inBuffer of 1kByte |
| | 8 | * Create an outBuffer of 1kByte |
| | 9 | * Look at the new Constructor interface, change it accordingly |
| | 10 | |
| | 11 | [[br]] |
| | 12 | [[br]] |
| | 13 | |
| | 14 | {{{ |
| | 15 | /* general notes: |
| | 16 | - The Stream function has some attributes, functions called up* and down* (eg. connectUpStream). The |
| | 17 | up direction signifies the direction from the network socket up to the Orxonox objects/classes. |
| | 18 | */ |
| | 19 | |
| | 20 | /* public functions */ |
| | 21 | public: |
| | 22 | |
| | 23 | /* |
| | 24 | * This constructor creates a new DataStream and connects it to both streams (upStream, downStream) |
| | 25 | */ |
| | 26 | DataStream(DataStream& upStream, DataStream& downStream); |
| | 27 | |
| | 28 | |
| | 29 | /* |
| | 30 | * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning |
| | 31 | * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this |
| | 32 | * Stream |
| | 33 | */ |
| | 34 | void connectUpStream(DataStream& upStream); |
| | 35 | |
| | 36 | |
| | 37 | /* |
| | 38 | * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning |
| | 39 | * that the stream is "closer" to the NetworkSocket. |
| | 40 | */ |
| | 41 | void connectDownStream(DataStream& downStream); |
| | 42 | |
| | 43 | |
| | 44 | /* |
| | 45 | * This function disconnects the upStream and sets it to NULL |
| | 46 | */ |
| | 47 | void disconnectUpStream(); |
| | 48 | |
| | 49 | |
| | 50 | /* |
| | 51 | * This function disconnects the downStream and sets it to NULL |
| | 52 | */ |
| | 53 | void disconnectDownStream(); |
| | 54 | |
| | 55 | |
| | 56 | /* |
| | 57 | * This function moves the data from the downStream object to the upStream object and changes the data if |
| | 58 | * necessary. This function is virtual and therefore needs to be extended by the derived class |
| | 59 | */ |
| | 60 | virtual void processData() = 0; |
| | 61 | |
| | 62 | |
| | 63 | /* protected functions - only visible inside the object and from derived classes */ |
| | 64 | proteced: |
| | 65 | |
| | 66 | /* |
| | 67 | * This function returns a reference to the local upData data array. So it can be read by an upper Stream |
| | 68 | * The reading function will have to copy the whole data and musn't just reference it! |
| | 69 | * This function is only called from other connected DataStreams to read the data. |
| | 70 | * |
| | 71 | * @param data: the binary array |
| | 72 | * @return: the length of the data |
| | 73 | */ |
| | 74 | virtual int passUp(byte* data); |
| | 75 | |
| | 76 | |
| | 77 | /* |
| | 78 | * This function writes the binary data to the local data. You will have to copy each byte and not only |
| | 79 | * dublicate it. |
| | 80 | * |
| | 81 | * @param data: the binary array |
| | 82 | * @param length: the length of the array |
| | 83 | */ |
| | 84 | virtual void passDown(byte* data, int length); |
| | 85 | |
| | 86 | |
| | 87 | }}} |