Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/synchronizeable.cc @ 6252

Last change on this file since 6252 was 6252, checked in by patrick, 18 years ago

network: less output

File size: 2.4 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
12### File Specific:
13   main-programmer: Silvan Nellen
14   co-programmer: Benjamin Wuest
15*/
16
17#define DEBUG_MODULE_NETWORK
18
19#include "synchronizeable.h"
20#include "netdefs.h"
21#include "network_manager.h"
22#include "network_stream.h"
23
24
25/**
26 *  default constructor
27 */
28Synchronizeable::Synchronizeable()
29{
30  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
31  owner = 0;
32  hostID = NetworkManager::getInstance()->getHostID();
33  this->setIsServer(this->hostID == 0);
34  uniqueID = -1;
35  this->networkStream = NULL;
36}
37
38
39
40/**
41 *  default destructor deletes all unneded stuff
42 */
43Synchronizeable::~Synchronizeable()
44{
45  if ( this->networkStream )
46    this->networkStream->disconnectSynchronizeable(*this);
47}
48
49/**
50 *  write data to NetworkStream
51 */
52void Synchronizeable::writeBytes(const byte* data, int length, int sender)
53{
54  PRINTF(5)("Synchronizeable::writeBytes was called\n");
55}
56
57/**
58 *  read data from NetworkStream
59 */
60int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
61{
62  PRINTF(5)("Synchronizeable::readBytes was called\n");
63}
64
65
66void Synchronizeable::writeDebug() const
67{}
68
69
70void Synchronizeable::readDebug() const
71{}
72
73
74/**
75 * Sets the server flag to a given value
76 * @param isServer: the boolean value which the server flag is to set to
77 */
78void Synchronizeable::setIsServer(bool isServer)
79{
80  if( isServer )
81    this->state = this->state | STATE_SERVER;
82  else
83    this->state = this->state & (~STATE_SERVER);
84}
85
86/**
87 * Sets the outofsync flag to a given value
88 * @param outOfSync: the boolean value which the outofsync flag is to set to
89 */
90void Synchronizeable::setIsOutOfSync(bool outOfSync)
91{
92  if( outOfSync )
93    this->state = this->state | STATE_OUTOFSYNC;
94  else
95    this->state = this->state & (~STATE_OUTOFSYNC);
96}
97
98/**
99 * Determines if the server flag is set
100 * @return true, if the server flag is true, false else
101 */
102bool Synchronizeable::isServer()
103{
104  return this->state & STATE_SERVER == STATE_SERVER;
105}
106
107/**
108 * Determines if the outofsync flag is set
109 * @return true, if the outofsync flag is true, false else
110 */
111bool Synchronizeable::isOutOfSync()
112{
113  return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
114}
115
116
117
Note: See TracBrowser for help on using the repository browser.