Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/data_stream.cc @ 6666

Last change on this file since 6666 was 5822, checked in by bensch, 19 years ago

orxonox/trunk: merged branches/network to the trunk
merged with command:
svn merge -r 5505:HEAD branches/network trunk

conflicts resolved in favor of the trunk (as always :))
also fixed a typo in the #include "SDL_tread.h"

File size: 2.8 KB
RevLine 
[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 */
23using namespace std;
24
[5649]25
26
[5611]27/**
[5722]28 * This is the empty constructor
[5611]29 */
[5649]30DataStream::DataStream()
31{
32  this->setClassID(CL_DATA_STREAM, "DataStream");
[5808]33  this->upBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
34  this->downBuffer = new byte[DATA_STREAM_BUFFER_SIZE];
[5649]35}
36
37/**
[5562]38 * This constructor creates a new DataStream and connects it to both streams (upStream, downStream)
[5554]39 */
[5611]40DataStream::DataStream(DataStream& inStream, DataStream& outStream)
[5569]41{
[5600]42    this->setClassID(CL_DATA_STREAM, "DataStream");
[5719]43    this->downStream = &outStream;
44    this->upStream = &inStream;
[5808]45
46    if( this->upBuffer)
47      delete[] this->upBuffer;
48    if( this->downBuffer)
49      delete[] this->downBuffer;
[5554]50}
51
52/**
53 *  standart deconstructor
54 */
[5562]55DataStream::~DataStream()
[5524]56{
[5569]57
[5524]58}
59
[5611]60
61/**
[5569]62 * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning
[5562]63 * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this
64 * Stream
[5554]65 */
[5562]66void DataStream::connectUpStream(DataStream& upStream)
[5524]67{
[5569]68
[5554]69}
70
[5562]71/**
[5569]72 * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning
[5562]73 * that the stream is "closer" to the NetworkSocket.
74 */
75void DataStream::connectDownStream(DataStream& upStream)
76{
[5569]77
[5562]78}
[5554]79
80/**
[5562]81 * This function disconnects the upStream and sets it to NULL
[5554]82 */
[5562]83void DataStream::disconnectUpStream()
[5554]84{
[5569]85
[5524]86}
87
[5562]88/**
89 * This function disconnects the downStream and sets it to NULL
90 */
91void DataStream::disconnectDownStream()
92{
[5569]93
[5562]94}
[5554]95
[5569]96
[5600]97/**
98 * Following functions are protected and only visible inside the object and from derived classes
99 */
[5554]100
101/**
[5562]102 * This function writes the binary data to the local data. You will have to copy each byte and not only dublicate
103 * it.
[5719]104 *
105 * @param data: the binary array
106 * @param length: the length of the array
[5554]107 */
[5719]108void passDown(byte* data, int length)
[5524]109{
[5808]110
[5524]111}
112
[5554]113
114/**
[5562]115 * This function returns a reference to the local upData data array. So it can be read by an upper Stream
116 * The reading function will have to copy the whole data and musn't just reference it!
117 * This function is only called from other connected DataStreams to read the data.
[5719]118 *
119 * @param data: the binary array
120 * @return: the length of the data
[5554]121 */
[5719]122int passUp(byte* data)
[5524]123{
[5808]124
[5524]125}
Note: See TracBrowser for help on using the repository browser.