Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 1 (modified by landauf, 16 years ago) (diff)

DataStream

This is an archived page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

Short description of the module and its functions:

Next Steps:

  • Create an inBuffer of 1kByte
  • Create an outBuffer of 1kByte
  • Look at the new Constructor interface, change it accordingly



/* general notes:
   - The Stream function has some attributes, functions called up* and down* (eg. connectUpStream). The
     up direction signifies the direction from the network socket up to the Orxonox objects/classes. 
*/

 /* public functions */
 public:

 /*
  * This constructor creates a new DataStream and connects it to both streams (upStream, downStream)
  */
  DataStream(DataStream& upStream, DataStream& downStream);


  /*
  * This function connects this stream to another stream. The connected DataStream is an up-stream, meaning 
  * that the stream is "further away" from the NetworkSocket. The local reference upStream will be set to this
  * Stream
  */
  void connectUpStream(DataStream& upStream);


 /*
  * This function connects this stream to another stream. The connected DataStream is an down-stream, meaning 
  * that the stream is "closer" to the NetworkSocket.
  */
  void connectDownStream(DataStream& downStream);


 /*
  * This function disconnects the upStream and sets it to NULL
  */
  void disconnectUpStream();


 /*
  * This function disconnects the downStream and sets it to NULL
  */
  void disconnectDownStream();


 /*
  * This function moves the data from the downStream object to the upStream object and changes the data if
  * necessary. This function is virtual and therefore needs to be extended by the derived class
  */
  virtual void processData() = 0;


 /* protected functions - only visible inside the object and from derived classes */
 proteced:

 /*
  * This function returns a reference to the local upData data array. So it can be read by an upper Stream
  * The reading function will have to copy the whole data and musn't just reference it!
  * This function is only called from other connected DataStreams to read the data.
  *
  * @param data: the binary array
  * @return: the length of the data
  */
  virtual int passUp(byte* data);


 /*
  * This function writes the binary data to the local data. You will have to copy each byte and not only
  * dublicate it.
  *
  * @param data: the binary array
  * @param length: the length of the array
  */
  virtual void passDown(byte* data, int length);