Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 30, 2009, 3:14:45 PM (15 years ago)
Author:
rgrieder
Message:

Unified enumeration layout according to the style guide (which I have edited recently ;)).
There is one exception though: XMLPort::Mode. Since that would involve 182 changed files, I have decided not to rename it for now. Moreover its syntax is not too bad ;)

Location:
code/branches/core4/src/network
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/network/NetworkPrereqs.h

    r3214 r3257  
    132132    namespace PacketFlag
    133133    {
    134       enum Enum
     134      enum Value
    135135      {
    136136        Reliable   = 1,
  • code/branches/core4/src/network/packet/Acknowledgement.cc

    r3214 r3257  
    3737#define PACKET_FLAGS_ACK    0
    3838#define _PACKETID           0
    39 #define _ACKID              _PACKETID + sizeof(packet::ENUM::Type)
     39#define _ACKID              _PACKETID + sizeof(packet::Type::Value)
    4040 
    4141Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
     
    4444  flags_ = flags_ | PACKET_FLAGS_ACK;
    4545  data_=new uint8_t[ getSize() ];
    46   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
     46  *(Type::Value *)(data_ + _PACKETID ) = Type::Acknowledgement;
    4747  *(uint32_t *)(data_ + _ACKID ) = id;
    4848  clientID_=clientID;
  • code/branches/core4/src/network/packet/Chat.cc

    r3214 r3257  
    3838#define   PACKET_FLAGS_CHAT PacketFlag::Reliable
    3939#define   _PACKETID         0
    40 const int _PLAYERID     =   _PACKETID + sizeof(ENUM::Type);
     40const int _PLAYERID     =   _PACKETID + sizeof(Type::Value);
    4141#define   _MESSAGELENGTH    _PLAYERID + sizeof(uint32_t)
    4242#define   _MESSAGE          _MESSAGELENGTH + sizeof(uint32_t)
     
    4848  messageLength_ = message.length()+1;
    4949  data_=new unsigned char[ getSize() ];
    50   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Chat;
     50  *(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
    5151  *(unsigned int *)(data_ + _PLAYERID ) = playerID;
    5252  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
  • code/branches/core4/src/network/packet/ClassID.cc

    r3214 r3257  
    7474  //set the appropriate packet id
    7575  assert(this->data_);
    76   *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;
     76  *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
    7777 
    7878  uint8_t *temp=data_+sizeof(uint32_t);
  • code/branches/core4/src/network/packet/DeleteObjects.cc

    r3214 r3257  
    3939#define PACKET_FLAG_DELETE  PacketFlag::Reliable
    4040#define _PACKETID           0
    41 #define _QUANTITY           _PACKETID + sizeof(ENUM::Type)
     41#define _QUANTITY           _PACKETID + sizeof(Type::Value)
    4242#define _OBJECTIDS          _QUANTITY + sizeof(uint32_t)
    4343 
     
    6262    return false;
    6363  COUT(4) << "sending DeleteObjects: ";
    64   unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1);
     64  unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
    6565  data_ = new uint8_t[size];
    6666  uint8_t *tdata = data_;
    67   *reinterpret_cast<ENUM::Type*>(tdata) = ENUM::DeleteObjects;
    68   tdata += sizeof(ENUM::Type);
     67  *reinterpret_cast<Type::Value*>(tdata) = Type::DeleteObjects;
     68  tdata += sizeof(Type::Value);
    6969  *(uint32_t *)tdata = number;
    7070  tdata += sizeof(uint32_t);
  • code/branches/core4/src/network/packet/FunctionCalls.cc

    r3214 r3257  
    4949  currentMemBlocks_ = 1;
    5050  data_=new uint8_t[ FUNCTIONCALLS_MEM_ALLOCATION ];
    51   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::FunctionCalls;
     51  *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls;
    5252  *(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0
    5353}
  • code/branches/core4/src/network/packet/FunctionIDs.cc

    r3214 r3257  
    6868  //set the appropriate packet id
    6969  assert(this->data_);
    70   *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::FunctionIDs;
     70  *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs;
    7171 
    7272  uint8_t *temp=data_+sizeof(uint32_t);
  • code/branches/core4/src/network/packet/Gamestate.h

    r3214 r3257  
    4747class _NetworkExport GamestateHeader{
    4848  public:
    49     GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }
     49    GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; }
    5050    GamestateHeader(uint8_t *data, GamestateHeader* h)
    5151    { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }
  • code/branches/core4/src/network/packet/Packet.cc

    r3214 r3257  
    6363Packet::Packet(){
    6464  flags_ = PACKET_FLAG_DEFAULT;
    65   packetDirection_ = ENUM::Outgoing;
     65  packetDirection_ = Direction::Outgoing;
    6666  clientID_=0;
    6767  data_=0;
     
    7676Packet::Packet(uint8_t *data, unsigned int clientID){
    7777  flags_ = PACKET_FLAG_DEFAULT;
    78   packetDirection_ = ENUM::Incoming;
     78  packetDirection_ = Direction::Incoming;
    7979  clientID_=clientID;
    8080  data_=data;
     
    125125
    126126bool Packet::send(){
    127   if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
     127  if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){
    128128    assert(0);
    129129    return false;
     
    147147  }
    148148#ifndef NDEBUG
    149   switch( *(ENUM::Type *)(data_ + _PACKETID) )
     149  switch( *(Type::Value *)(data_ + _PACKETID) )
    150150  {
    151     case ENUM::Acknowledgement:
    152     case ENUM::Chat:
    153     case ENUM::ClassID:
    154     case ENUM::Gamestate:
    155     case ENUM::Welcome:
    156     case ENUM::DeleteObjects:
    157     case ENUM::FunctionIDs:
    158     case ENUM::FunctionCalls:
     151    case Type::Acknowledgement:
     152    case Type::Chat:
     153    case Type::ClassID:
     154    case Type::Gamestate:
     155    case Type::Welcome:
     156    case Type::DeleteObjects:
     157    case Type::FunctionIDs:
     158    case Type::FunctionCalls:
    159159      break;
    160160    default:
     
    175175  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    176176  Packet *p = 0;
    177   COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    178   switch( *(ENUM::Type *)(data + _PACKETID) )
     177  COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
     178  switch( *(Type::Value *)(data + _PACKETID) )
    179179  {
    180     case ENUM::Acknowledgement:
     180    case Type::Acknowledgement:
    181181      COUT(5) << "ack" << std::endl;
    182182      p = new Acknowledgement( data, clientID );
    183183      break;
    184     case ENUM::Chat:
     184    case Type::Chat:
    185185      COUT(5) << "chat" << std::endl;
    186186      p = new Chat( data, clientID );
    187187      break;
    188     case ENUM::ClassID:
     188    case Type::ClassID:
    189189      COUT(5) << "classid" << std::endl;
    190190      p = new ClassID( data, clientID );
    191191      break;
    192     case ENUM::Gamestate:
     192    case Type::Gamestate:
    193193      COUT(5) << "gamestate" << std::endl;
    194194      // TODO: remove brackets
    195195      p = new Gamestate( data, clientID );
    196196      break;
    197     case ENUM::Welcome:
     197    case Type::Welcome:
    198198      COUT(5) << "welcome" << std::endl;
    199199      p = new Welcome( data, clientID );
    200200      break;
    201     case ENUM::DeleteObjects:
     201    case Type::DeleteObjects:
    202202      COUT(5) << "deleteobjects" << std::endl;
    203203      p = new DeleteObjects( data, clientID );
    204204      break;
    205     case ENUM::FunctionCalls:
     205    case Type::FunctionCalls:
    206206      COUT(5) << "functionCalls" << std::endl;
    207207      p = new FunctionCalls( data, clientID );
    208208      break;
    209     case ENUM::FunctionIDs:
     209    case Type::FunctionIDs:
    210210      COUT(5) << "functionIDs" << std::endl;
    211211      p = new FunctionIDs( data, clientID );
  • code/branches/core4/src/network/packet/Packet.h

    r3214 r3257  
    3636namespace packet{
    3737
    38 namespace ENUM{
    39   enum Direction{
     38namespace Direction{
     39  enum Value{
    4040    Incoming,
    4141    Outgoing,
    4242    Bidirectional
    4343  };
    44   enum Type{
     44}
     45namespace Type{
     46  enum Value{
    4547    Acknowledgement,
    4648    Chat,
     
    8486    uint32_t flags_;
    8587    unsigned int clientID_;
    86     ENUM::Direction packetDirection_;
     88    Direction::Value packetDirection_;
    8789    /** Pointer to the data. Be careful when deleting it because it might
    8890        point to a location that was allocated by ENet.
  • code/branches/core4/src/network/packet/Welcome.cc

    r3214 r3257  
    4141#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4242#define _PACKETID             0
    43 #define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
     43#define _CLIENTID             _PACKETID + sizeof(Type::Value)
    4444#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
    4545
     
    5151  data_=new uint8_t[ getSize() ];
    5252  assert(data_);
    53   *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
     53  *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome;
    5454  *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
    5555  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
     
    7070
    7171unsigned int Welcome::getSize() const{
    72   return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t);
     72  return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
    7373}
    7474
  • code/branches/core4/src/network/synchronisable/Synchronisable.cc

    r3239 r3257  
    6565    this->dataSize_ = 0;
    6666    // set standard priority
    67     this->setPriority( priority::normal );
     67    this->setPriority( Priority::Normal );
    6868
    6969    // get creator id
  • code/branches/core4/src/network/synchronisable/Synchronisable.h

    r3214 r3257  
    5151{
    5252
    53   namespace objectDirection{
    54     enum objectdirection{
    55       toclient=0x1,
    56       toserver=0x2,
    57       bidirectional=0x3
     53  namespace ObjectDirection{
     54    enum Value{
     55      ToClient=0x1,
     56      ToServer=0x2,
     57      Bidirectional=0x3
    5858    };
    5959  }
    6060
    61   namespace priority{
    62     enum prio{
    63       very_high   = -100,
    64       high        = -15,
    65       normal      = 0,
    66       low         = 15,
    67       very_low    = 100
     61  namespace Priority{
     62    enum Value{
     63      VeryHigh    = -100,
     64      High        = -15,
     65      Normal      = 0,
     66      Low         = 15,
     67      VeryLow     = 100
    6868    };
    6969  }
  • code/branches/core4/src/network/synchronisable/SynchronisableVariable.h

    r3214 r3257  
    4141namespace orxonox{
    4242 
    43   namespace variableDirection{
    44     enum syncdirection{
    45       toclient=0x1,
    46       toserver=0x2
     43  namespace VariableDirection{
     44    enum Value{
     45      ToClient=0x1,
     46      ToServer=0x2
    4747    };
    48     enum bidirectional{
    49       serverMaster=0x1,
    50       clientMaster=0x2
     48  }
     49  namespace Bidirectionality{
     50    enum Value{
     51      ServerMaster=0x1,
     52      ClientMaster=0x2
    5153    };
    5254  }
     
    6971  {
    7072    public:
    71       SynchronisableVariable(T& variable, uint8_t syncDirection=variableDirection::toclient, NetworkCallbackBase *cb=0);
     73      SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=0);
    7274      virtual ~SynchronisableVariable();
    7375
     
    8890  {
    8991    public:
    90       SynchronisableVariableBidirectional(T& variable, uint8_t master=variableDirection::serverMaster, NetworkCallbackBase *cb=0);
     92      SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
    9193      virtual ~SynchronisableVariableBidirectional();
    9294     
Note: See TracChangeset for help on using the changeset viewer.