Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6341 in orxonox.OLD for trunk/src/lib/network/synchronizeable.cc


Ignore:
Timestamp:
Dec 30, 2005, 1:57:12 AM (18 years ago)
Author:
bensch
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/synchronizeable.cc

    r6145 r6341  
    2828Synchronizeable::Synchronizeable()
    2929{
    30 
     30  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
    3131  owner = 0;
     32  state = 0;
    3233  hostID = NetworkManager::getInstance()->getHostID();
     34  this->setIsServer(this->hostID == 0);
    3335  uniqueID = -1;
    3436  this->networkStream = NULL;
    35   //state = ?;
    36 
     37  this->setRequestedSync( false );
    3738}
    3839
    39 /**
    40  *  default constructor
    41  */
    42 Synchronizeable::Synchronizeable(const char* name)
    43 {
    44   this->setName(name);
    45   this->networkStream = NULL;
    46 }
    4740
    4841
     
    5952 *  write data to NetworkStream
    6053 */
    61 void Synchronizeable::writeBytes(const byte* data, int length)
     54int Synchronizeable::writeBytes(const byte* data, int length, int sender)
    6255{
    63   PRINTF(1)("Synchronizeable::writeBytes was called\n");
     56  PRINTF(5)("Synchronizeable::writeBytes was called\n");
    6457}
    6558
     
    6962int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
    7063{
    71   PRINTF(1)("Synchronizeable::readBytes was called\n");
     64  PRINTF(5)("Synchronizeable::readBytes was called\n");
    7265}
    7366
     
    10396  else
    10497    this->state = this->state & (~STATE_OUTOFSYNC);
     98  //PRINTF(0)("isoutofsync %s %d\n", this->getClassName(), state);
    10599}
    106100
     
    111105bool Synchronizeable::isServer()
    112106{
    113   return this->state & STATE_SERVER == STATE_SERVER;
     107  return (this->state & STATE_SERVER) >0;
    114108}
    115109
     
    120114bool Synchronizeable::isOutOfSync()
    121115{
    122   return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
     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);
    123138}
    124139
Note: See TracChangeset for help on using the changeset viewer.