Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6061 was 6060, checked in by bwuest, 18 years ago

Network changes

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