Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9303 was 8623, checked in by bensch, 18 years ago

orxonox/trunk: merged the network branche back here
merged with command:
svn merge -r8230:HEAD https://svn.orxonox.net/orxonox/branches/network .
conflicts resolved in favour of the network branche (conflicts were in network)

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