Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10473


Ignore:
Timestamp:
May 25, 2015, 2:04:43 PM (10 years ago)
Author:
landauf
Message:

bugfix and continuation of the last commit:

  • FunctionCall::execute() now returns the correct value (was inverted accidentally)
  • FunctionCall::setCall() new calculates the correct callsize (still included the 8bits for isStatic that was removed in the previous commit)
  • static and member network functions are now treated equally throughout the whole system (only the macros make a difference)
Location:
code/branches/core7/src/libraries/network
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/network/FunctionCall.cc

    r10472 r10473  
    5252  {
    5353    case 0:
    54       return !fct->call(this->objectID_);
     54      return fct->call(this->objectID_);
    5555    case 1:
    56       return !fct->call(this->objectID_, this->arguments_[0]);
     56      return fct->call(this->objectID_, this->arguments_[0]);
    5757    case 2:
    58       return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
     58      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
    5959    case 3:
    60       return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
     60      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
    6161    case 4:
    62       return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
     62      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
    6363    case 5:
    64       return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
     64      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
    6565    default:
    6666      assert(0);
     
    6969}
    7070
    71 void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
     71void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
    7272
    7373  // first determine the size that has to be reserved for this call
    74   uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
    75   uint32_t nrOfArguments = 0;
    76   if(mt1)
    77   {
    78     nrOfArguments++;
    79     callsize += mt1->getNetworkSize();
    80     this->arguments_.push_back(*mt1);
    81     if(mt2)
    82     {
    83       nrOfArguments++;
    84       callsize += mt2->getNetworkSize();
    85       this->arguments_.push_back(*mt2);
    86       if(mt3)
    87       {
    88         nrOfArguments++;
    89         callsize += mt3->getNetworkSize();
    90         this->arguments_.push_back(*mt3);
    91         if(mt4)
    92         {
    93           nrOfArguments++;
    94           callsize += mt4->getNetworkSize();
    95           this->arguments_.push_back(*mt4);
    96           if(mt5)
    97           {
    98             nrOfArguments++;
    99             callsize += mt5->getNetworkSize();
    100             this->arguments_.push_back(*mt5);
    101           }
    102         }
    103       }
    104     }
    105   }
    106   this->nrOfArguments_ = nrOfArguments;
    107   this->size_ = callsize;
    108   this->functionID_ = networkID;
    109 }
    110 
    111 void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
    112 
    113   // first determine the size that has to be reserved for this call
    114   uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
     74  uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
    11575  uint32_t nrOfArguments = 0;
    11676  if(mt1)
     
    146106  this->nrOfArguments_ = nrOfArguments;
    147107  this->functionID_ = networkID;
     108  this->objectID_ = objectID;
    148109  this->size_ = callsize;
    149   this->objectID_ = objectID;
    150110}
    151111
  • code/branches/core7/src/libraries/network/FunctionCall.h

    r10472 r10473  
    5252  bool execute();
    5353
    54   void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    55   void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
     54  void setCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    5655 
    5756  void saveData( uint8_t*& mem );
     
    6059  uint32_t                  nrOfArguments_;
    6160  uint32_t                  functionID_;
    62   uint32_t                  objectID_;
     61  uint32_t                  objectID_; // equals OBJECTID_UNKNOWN for static functions
    6362  uint32_t                  size_;
    6463  std::vector<MultiType>    arguments_;
  • code/branches/core7/src/libraries/network/FunctionCallManager.cc

    r8403 r10473  
    3939std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
    4040
    41 // Static calls
    4241
    43 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
     42void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID)
    4443{
    4544  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    4847    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    4948  }
    50   FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
     49  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID);
    5150}
    52 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
     51void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
    5352{
    5453  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    5756    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    5857  }
    59   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
     58  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1);
    6059}
    61 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
     60void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
    6261{
    6362  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    6665    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    6766  }
    68   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
     67  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2);
    6968}
    70 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
     69void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    7170{
    7271  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    7574    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    7675  }
    77   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
     76  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3);
    7877}
    79 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
     78void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    8079{
    8180  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    8483    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    8584  }
    86   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
     85  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
    8786}
    88 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
     87void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    8988{
    9089  if(sPeerMap_.find(peerID)==sPeerMap_.end())
     
    9392    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    9493  }
    95   FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
    96 }
    97 
    98 
    99 // MemberCalls
    100 
    101 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
    102 {
    103   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    104   {
    105     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    106     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    107   }
    108   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
    109 }
    110 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
    111 {
    112   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    113   {
    114     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    115     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    116   }
    117   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
    118 }
    119 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
    120 {
    121   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    122   {
    123     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    124     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    125   }
    126   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
    127 }
    128 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    129 {
    130   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    131   {
    132     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    133     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    134   }
    135   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
    136 }
    137 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    138 {
    139   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    140   {
    141     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    142     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    143   }
    144   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
    145 }
    146 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    147 {
    148   if(sPeerMap_.find(peerID)==sPeerMap_.end())
    149   {
    150     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
    151     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
    152   }
    153   FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
     94  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
    15495}
    15596
  • code/branches/core7/src/libraries/network/FunctionCallManager.h

    r7801 r10473  
    4646{
    4747public:
    48   static void addCallStatic(uint32_t functionID, uint32_t peerID);
    49   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
    50   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
    51   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
    52   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
    53   static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    54 
    55   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
    56   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
    57   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
    58   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
    59   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
    60   static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
     48  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID);
     49  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
     50  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
     51  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
     52  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
     53  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    6154
    6255  static void sendCalls(orxonox::Host* host);
  • code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h

    r10471 r10473  
    5151            NetworkFunctionPointer p1; \
    5252            copyPtr( functionPointer, p1 ); \
    53             FunctionCallManager::addCallStatic(NetworkFunctionManager::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
     53            FunctionCallManager::addCall(NetworkFunctionManager::getFunction(p1)->getNetworkID(), OBJECTID_UNKNOWN, __VA_ARGS__); \
    5454        }
    5555
     
    5959            NetworkFunctionPointer p1; \
    6060            copyPtr( &class::function, p1 ); \
    61             FunctionCallManager::addCallMember(NetworkFunctionManager::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
     61            FunctionCallManager::addCall(NetworkFunctionManager::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
    6262        }
    6363
  • code/branches/core7/src/libraries/network/packet/FunctionCalls.cc

    r8351 r10473  
    8282}
    8383
    84 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
     84void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
    8585{
    8686  assert(!isDataENetAllocated());
    8787 
    8888  this->functionCalls_.push(orxonox::FunctionCall());
    89   this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
    90   this->currentSize_ += this->functionCalls_.back().getSize();
    91 }
    92 
    93 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
    94 {
    95   assert(!isDataENetAllocated());
    96  
    97   this->functionCalls_.push(orxonox::FunctionCall());
    98   this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
     89  this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
    9990  this->currentSize_ += this->functionCalls_.back().getSize();
    10091}
  • code/branches/core7/src/libraries/network/packet/FunctionCalls.h

    r7801 r10473  
    5656  virtual bool process(orxonox::Host* host);
    5757
    58   void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    59   void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
     58  void addCall( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
    6059  virtual bool send(orxonox::Host* host);
    6160private:
Note: See TracChangeset for help on using the changeset viewer.