Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/lib/network/synchronizeable_var


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

Location:
trunk/src/lib/network/synchronizeable_var
Files:
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.cc

    r7954 r9406  
    1616
    1717#include "synchronizeable_bool.h"
     18#include <cassert>
    1819
    1920
     
    4445{
    4546  assert( maxLength >= 1 );
    46  
     47
    4748  buf[0] = ( *vPtrIn ) ? 1 : 0;
    48  
     49
    4950  return 1;
    5051}
     
    5960{
    6061  assert( maxLength >= 1 );
    61  
     62
    6263  bool oldVal = *vPtrOut;
    63  
     64
    6465  *vPtrOut = buf[0] != 0;
    65  
     66
    6667  setHasChanged( oldVal != *vPtrOut );
    67  
     68
    6869  return 1;
    6970}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_bool.h

    r7954 r9406  
    22 * @file synchronizeable_int.h
    33 * @brief Definition of SynchronizeableInt
    4 */
    5 
    6 #include "synchronizeable_var/synchronizeable_var.h"
     4 */
    75
    86#ifndef _SYNCHRONIZEABLE_BOOL_H
    97#define _SYNCHRONIZEABLE_BOOL_H
    108
     9#include "synchronizeable_var.h"
     10
    1111class SynchronizeableBool : public SynchronizeableVar {
    1212
    1313  public:
    14     SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     14    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1515    virtual ~SynchronizeableBool();
    16    
     16
    1717    virtual int writeToBuf( byte * buf, int maxLength );
    1818    virtual int readFromBuf( byte * buf, int maxLength );
    19    
     19
    2020    /**
    2121     * check if writeToBuf will return the same size every time
     
    2323     */
    2424    virtual bool hasStaticSize(){ return true; };
    25    
     25
    2626    virtual void debug();
    27    
     27
    2828  private:
    2929    bool * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_float.cc

    r7954 r9406  
    1717#include "synchronizeable_float.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    4647{
    4748  int res = Converter::floatToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res == FLOATSIZE );
    50  
     51
    5152  return res;
    5253}
     
    6162{
    6263  assert( maxLength >= FLOATSIZE );
    63  
     64
    6465  float oldVal = *vPtrOut;
    65  
     66
    6667  int res = Converter::byteArrayToFloat( buf, vPtrOut );
    67  
     68
    6869  setHasChanged( oldVal != *vPtrOut );
    69  
     70
    7071  assert( res == FLOATSIZE );
    71  
     72
    7273  return res;
    7374}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_float.h

    r7954 r9406  
    22 * @file synchronizeable_float.h
    33 * @brief Definition of SynchronizeableFloat
    4 */
     4 */
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    76
    87#ifndef _SYNCHRONIZEABLE_FLOAT_H
    98#define _SYNCHRONIZEABLE_FLOAT_H
    109
     10#include "synchronizeable_var.h"
     11
    1112class SynchronizeableFloat : public SynchronizeableVar {
    1213
    1314  public:
    14     SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableFloat();
    16    
     17
    1718    virtual int writeToBuf( byte * buf, int maxLength );
    1819    virtual int readFromBuf( byte * buf, int maxLength );
    19        
     20
    2021    /**
    2122     * check if writeToBuf will return the same size every time
     
    2324     */
    2425    virtual bool hasStaticSize(){ return true; };
    25    
     26
    2627    virtual void debug();
    27    
     28
    2829  private:
    2930    float * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_int.cc

    r7954 r9406  
    1818#include "converter.h"
    1919
     20#include <cassert>
    2021
    2122/**
     
    4647{
    4748  int res = Converter::intToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res == INTSIZE );
    50  
     51
    5152  return res;
    5253}
     
    6162{
    6263  assert( maxLength >= INTSIZE );
    63  
     64
    6465  int oldVal = *vPtrOut;
    65  
     66
    6667  int res = Converter::byteArrayToInt( buf, vPtrOut );
    67  
     68
    6869  setHasChanged( oldVal != *vPtrOut );
    69  
     70
    7071  assert( res == INTSIZE );
    71  
     72
    7273  return res;
    7374}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_int.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    76
    87#ifndef _SYNCHRONIZEABLE_INT_H
    98#define _SYNCHRONIZEABLE_INT_H
    109
     10#include "synchronizeable_var.h"
     11
    1112class SynchronizeableInt : public SynchronizeableVar {
    1213
    1314  public:
    14     SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableInt();
    16    
     17
    1718    virtual int writeToBuf( byte * buf, int maxLength );
    1819    virtual int readFromBuf( byte * buf, int maxLength );
    19    
     20
    2021    /**
    2122     * check if writeToBuf will return the same size every time
     
    2324     */
    2425    virtual bool hasStaticSize(){ return true; };
    25    
     26
    2627    virtual void debug();
    27    
     28
    2829  protected:
    2930    int * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc

    r7954 r9406  
    1717#include "synchronizeable_quaternion.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    9899  assert( res > 0 );
    99100  n += res;
    100  
     101
    101102  Quaternion oldVal = *vPtrOut;
    102103
    103104  *vPtrOut = Quaternion( Vector(x, y, z), w );
    104  
     105
    105106  setHasChanged( ! ( oldVal == *vPtrOut ) );
    106107
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 
    86#ifndef _SYNCHRONIZEABLE_QUATERNION_H
    97#define _SYNCHRONIZEABLE_QUATERNION_H
     8
     9#include "synchronizeable_var.h"
    1010
    1111#include "quaternion.h"
     
    1414
    1515  public:
    16     SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1717    virtual ~SynchronizeableQuaternion();
    18    
     18
    1919    virtual int writeToBuf( byte * buf, int maxLength );
    2020    virtual int readFromBuf( byte * buf, int maxLength );
    21        
     21
    2222    /**
    2323     * check if writeToBuf will return the same size every time
     
    2525     */
    2626    virtual bool hasStaticSize(){ return true; };
    27    
     27
    2828    virtual void debug();
    29    
     29
    3030  private:
    3131    Quaternion * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_string.cc

    r8147 r9406  
    1717#include "synchronizeable_string.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    4647{
    4748  int res = Converter::stringToByteArray( *vPtrIn, buf, maxLength );
    48  
     49
    4950  assert( res > 0 );
    5051  assert( res == vPtrIn->length()+INTSIZE );
    51  
     52
    5253  return res;
     54}
     55
     56int SynchronizeableString::getSize()
     57{
     58   return vPtrIn->length()+INTSIZE;
    5359}
    5460
     
    6268{
    6369  std::string oldVal = *vPtrOut;
    64      
     70
    6571  int res = Converter::byteArrayToString( buf, *vPtrOut, maxLength );
    66  
     72
    6773  setHasChanged( oldVal != *vPtrOut );
    68  
     74
    6975  if ( res < 0 )
    7076  {
     
    7278  }
    7379  assert( res > 0 );
    74  
     80
    7581  return res;
    7682}
     
    94100{
    95101  std::string t;
    96  
     102
    97103  int res = Converter::byteArrayToString( buf, t, maxLength );
    98  
     104
    99105  assert( res > 0 );
    100  
     106
    101107  return res;
    102108}
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_string.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 #include "converter.h"
    8 
    96#ifndef _SYNCHRONIZEABLE_STRING_H
    107#define _SYNCHRONIZEABLE_STRING_H
     8
     9#include "synchronizeable_var.h"
    1110
    1211#include <string>
     
    1514
    1615  public:
    17     SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1817    virtual ~SynchronizeableString();
    19    
     18
    2019    virtual int writeToBuf( byte * buf, int maxLength );
    2120    virtual int readFromBuf( byte * buf, int maxLength );
    22    
    23        
     21
     22
    2423    /**
    2524     * check if writeToBuf will return the same size every time
     
    2726     */
    2827    virtual bool hasStaticSize(){ return false; };
    29    
    30     virtual int getSize(){ return vPtrIn->length()+INTSIZE; }
    31    
     28
     29    virtual int getSize();
     30
    3231    virtual int getSizeFromBuf( byte * buf, int maxLength );
    33    
     32
    3433    virtual void debug();
    35    
     34
    3635  private:
    3736    std::string * vPtrIn;       //!< pointer to data (read)
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_uint.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_int.h"
    76
    87#ifndef _SYNCHRONIZEABLE_UINT_H
    98#define _SYNCHRONIZEABLE_UINT_H
    109
     10#include "synchronizeable_int.h"
     11
    1112class SynchronizeableUInt : public SynchronizeableInt {
    1213
    1314  public:
    14     SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     15    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1516    virtual ~SynchronizeableUInt();
    16    
     17
    1718    virtual void debug();
    1819
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_var.cc

    r7954 r9406  
    1616
    1717#include "synchronizeable_var.h"
    18 
     18#include "netdefs.h"
     19#include <cassert>
    1920
    2021
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h

    r7954 r9406  
    77#define _SYNCHRONIZEABLE_VAR_H
    88
     9#include "nettypes.h"
    910#include <string>
    10 #include "netdefs.h"
    11 #include <assert.h>
    1211
    1312enum {
    14   PERMISSION_SERVER = 1,
    15   PERMISSION_OWNER  = 2,
    16   PERMISSION_ALL    = 4
     13  PERMISSION_MASTER_SERVER = 1,
     14  PERMISSION_PROXY_SERVER  = 2,
     15  PERMISSION_OWNER         = 4,
     16  PERMISSION_ALL           = 8
    1717};
    1818
     
    2020
    2121  public:
    22     SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_SERVER, int priority = 0 );
     22    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    2323    virtual ~SynchronizeableVar();
    2424
     
    2828     */
    2929    inline bool beWatched(){ return this->bWatched; }
    30    
    31     /** 
     30
     31    /**
    3232     * set flag if synchronizeable wants to be informed on changes
    3333     */
     
    9696     */
    9797    inline void resetPriority() { this->priority = this->realPriority; }
    98    
     98
    9999    /**
    100100     * reads actual size from buffer. this is used when size is not constant
     
    104104     */
    105105    virtual inline int getSizeFromBuf( byte * buf, int maxLength ){ return this->getSize(); }
    106    
     106
    107107    /**
    108108     * set variable id
     
    110110     */
    111111    inline void setVarId( int id ){ this->varId = id; }
    112    
    113     /** 
     112
     113    /**
    114114     * get variable id
    115115     * @return variable id
    116116     */
    117117    inline int getVarId(){ return varId; }
    118    
     118
    119119    /**
    120120     * set hasChanged
     
    122122     */
    123123    inline void setHasChanged( bool changed ){ this->changed = changed; }
    124    
    125     /** 
     124
     125    /**
    126126     * get hasChanged
    127127     * @return variable id
    128128     */
    129129    inline bool getHasChanged(){ return changed; }
    130    
     130
    131131    /**
    132132     * print out variable value
     
    137137  private:
    138138    bool bWatched;      //!< true if synchronizeable wants to be informed on changes
    139    
     139
    140140    int permission;     //!< who is allowed to change this var
    141141    int priority;       //!< priority assigned to var
    142142    int realPriority;   //!< priority assigned to var, increased every time not sent
    143143    int varId;          //!< id to identify varables
    144    
     144
    145145    bool changed;       //!< true if last readFromBuf changed anything
    146146
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.cc

    r7954 r9406  
    1717#include "synchronizeable_vector.h"
    1818#include "converter.h"
     19#include <cassert>
    1920
    2021
     
    7980  int res;
    8081  int n = 0;
    81  
     82
    8283  Vector oldVec = *vPtrOut;
    8384
     
    9596
    9697  *vPtrOut = Vector( x, y, z );
    97  
     98
    9899  setHasChanged( !(*vPtrOut == oldVec) );
    99100
  • trunk/src/lib/network/synchronizeable_var/synchronizeable_vector.h

    r7954 r9406  
    44*/
    55
    6 #include "synchronizeable_var/synchronizeable_var.h"
    7 
    86#ifndef _SYNCHRONIZEABLE_VECTOR_H
    97#define _SYNCHRONIZEABLE_VECTOR_H
     8
     9#include "synchronizeable_var.h"
    1010
    1111#include "vector.h"
     
    1414
    1515  public:
    16     SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_SERVER, int priority = 0 );
     16    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
    1717    virtual ~SynchronizeableVector();
    18    
     18
    1919    virtual int writeToBuf( byte * buf, int maxLength );
    2020    virtual int readFromBuf( byte * buf, int maxLength );
    21    
     21
    2222    /**
    2323     * check if writeToBuf will return the same size every time
     
    2525     */
    2626    virtual bool hasStaticSize(){ return true; }
    27    
     27
    2828    virtual void debug();
    29    
     29
    3030  private:
    3131    Vector * vPtrIn;       //!< pointer to data (read)
Note: See TracChangeset for help on using the changeset viewer.