Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6476 was 6341, checked in by bensch, 19 years ago

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File size: 3.1 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  state = 0;
33  hostID = NetworkManager::getInstance()->getHostID();
34  this->setIsServer(this->hostID == 0);
35  uniqueID = -1;
36  this->networkStream = NULL;
37  this->setRequestedSync( false );
38}
39
40
41
42/**
43 *  default destructor deletes all unneded stuff
44 */
45Synchronizeable::~Synchronizeable()
46{
47  if ( this->networkStream )
48    this->networkStream->disconnectSynchronizeable(*this);
49}
50
51/**
52 *  write data to NetworkStream
53 */
54int Synchronizeable::writeBytes(const byte* data, int length, int sender)
55{
56  PRINTF(5)("Synchronizeable::writeBytes was called\n");
57}
58
59/**
60 *  read data from NetworkStream
61 */
62int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
63{
64  PRINTF(5)("Synchronizeable::readBytes was called\n");
65}
66
67
68void Synchronizeable::writeDebug() const
69{}
70
71
72void Synchronizeable::readDebug() const
73{}
74
75
76/**
77 * Sets the server flag to a given value
78 * @param isServer: the boolean value which the server flag is to set to
79 */
80void Synchronizeable::setIsServer(bool isServer)
81{
82  if( isServer )
83    this->state = this->state | STATE_SERVER;
84  else
85    this->state = this->state & (~STATE_SERVER);
86}
87
88/**
89 * Sets the outofsync flag to a given value
90 * @param outOfSync: the boolean value which the outofsync flag is to set to
91 */
92void Synchronizeable::setIsOutOfSync(bool outOfSync)
93{
94  if( outOfSync )
95    this->state = this->state | STATE_OUTOFSYNC;
96  else
97    this->state = this->state & (~STATE_OUTOFSYNC);
98  //PRINTF(0)("isoutofsync %s %d\n", this->getClassName(), state);
99}
100
101/**
102 * Determines if the server flag is set
103 * @return true, if the server flag is true, false else
104 */
105bool Synchronizeable::isServer()
106{
107  return (this->state & STATE_SERVER) >0;
108}
109
110/**
111 * Determines if the outofsync flag is set
112 * @return true, if the outofsync flag is true, false else
113 */
114bool Synchronizeable::isOutOfSync()
115{
116  return (this->state & STATE_OUTOFSYNC) >0;
117}
118
119/**
120 * Determines if the requestedSync flag is set
121 * @return true, if the requestedSync flag is true, false else
122 */
123bool Synchronizeable::requestedSync()
124{
125  return (this->state & STATE_REQUESTEDSYNC) >0;
126}
127
128/**
129 * Sets the requestedsync flag to a given value
130 * @param requestedSync: the boolean value which the requestedsync flag is to set to
131 */
132void Synchronizeable::setRequestedSync( bool requestedSync )
133{
134  if( requestedSync )
135    this->state = this->state | STATE_REQUESTEDSYNC;
136  else
137    this->state = this->state & (~STATE_REQUESTEDSYNC);
138}
139
140
141
Note: See TracBrowser for help on using the repository browser.