Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added handshake

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