Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/network/data_stream.cc @ 9690

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

some network-stuff

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