Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6053 was 6053, checked in by rennerc, 18 years ago

handshake works now

File size: 2.3 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
23
24/**
25 *  default constructor
26 */
27Synchronizeable::Synchronizeable()
28{
29
30  //owner = ?;
31  hostID = NetworkManager::getInstance()->getHostID();
32  //state = ?;
33
34}
35
36/**
37 *  default constructor
38 */
39Synchronizeable::Synchronizeable(const char* name)
40{
41  this->setName(name);
42}
43
44
45/**
46 *  default destructor deletes all unneded stuff
47 */
48Synchronizeable::~Synchronizeable()
49{}
50
51/**
52 *  write data to NetworkStream
53 */
54void Synchronizeable::writeBytes(const byte* data, int length)
55{
56  PRINTF(1)("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(1)("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}
99
100/**
101 * Determines if the server flag is set
102 * @return true, if the server flag is true, false else
103 */
104bool Synchronizeable::isServer()
105{
106  return this->state & STATE_SERVER == STATE_SERVER;
107}
108
109/**
110 * Determines if the outofsync flag is set
111 * @return true, if the outofsync flag is true, false else
112 */
113bool Synchronizeable::isOutOfSync()
114{
115  return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
116}
117
118
119
Note: See TracBrowser for help on using the repository browser.