Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/synchronizeable.cc @ 6140

Last change on this file since 6140 was 6139, checked in by patrick, 19 years ago

trunk: merged branche network with trunk using command: svn merge -r5999:HEAD, conflicts resolved in favor of the trunk bla

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