Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15335/libplayercore

Modified Files:
        message.cc message.h player.h 
Log Message:
applied Radu's patches to fix some inconsistencies in the core components

Index: player.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/player.h,v
retrieving revision 1.109
retrieving revision 1.110
diff -C2 -d -r1.109 -r1.110
*** player.h    19 Jul 2006 05:43:26 -0000      1.109
--- player.h    26 Jul 2006 17:14:16 -0000      1.110
***************
*** 50,54 ****
  #define PLAYER_MAX_DEVICES             256
  /** Default maximum length for a message queue */
! #define PLAYER_MSGQUEUE_DEFAULT_MAXLEN 32
  /** String that is spit back as a banner on connection */
  #define PLAYER_IDENT_STRING    "Player v."
--- 50,54 ----
  #define PLAYER_MAX_DEVICES             256
  /** Default maximum length for a message queue */
! #define PLAYER_MSGQUEUE_DEFAULT_MAXLEN 1024
  /** String that is spit back as a banner on connection */
  #define PLAYER_IDENT_STRING    "Player v."
***************
*** 3003,3006 ****
--- 3003,3012 ----
  
  
+ /** A replace rule can either accept, replace or ignore 
+ a message.*/
+ #define PLAYER_PLAYER_MSG_REPLACE_RULE_ACCEPT  0
+ #define PLAYER_PLAYER_MSG_REPLACE_RULE_REPLACE 1
+ #define PLAYER_PLAYER_MSG_REPLACE_RULE_IGNORE  2
+ 
  /** @brief Request/reply: Get the list of available devices.
  

Index: message.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/message.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** message.h   17 Mar 2006 21:22:05 -0000      1.16
--- message.h   26 Jul 2006 17:14:16 -0000      1.17
***************
*** 159,163 ****
    public:
      MessageReplaceRule(int _host, int _robot, int _interf, int _index,
!                        int _type, int _subtype, bool _replace) :
              host(_host), robot(_robot), interf(_interf), index(_index),
              type(_type), subtype(_subtype), replace(_replace), next(NULL) {}
--- 159,163 ----
    public:
      MessageReplaceRule(int _host, int _robot, int _interf, int _index,
!                        int _type, int _subtype, int _replace) :
              host(_host), robot(_robot), interf(_interf), index(_index),
              type(_type), subtype(_subtype), replace(_replace), next(NULL) {}
***************
*** 181,185 ****
      bool Equivalent (int _host, int _robot, int _interf, int _index, int 
_type, int _subtype)
      {
!       return (host == _host && robot == _robot && _interf && index == _index 
&&
            type == _type && subtype == _subtype);
      }
--- 181,185 ----
      bool Equivalent (int _host, int _robot, int _interf, int _index, int 
_type, int _subtype)
      {
!       return (host == _host && robot == _robot && interf ==_interf && index 
== _index &&
            type == _type && subtype == _subtype);
      }
***************
*** 187,191 ****
      // To replace, or not to replace
      // That is the question
!     bool replace;
      // Next rule in the list
      MessageReplaceRule* next;
--- 187,191 ----
      // To replace, or not to replace
      // That is the question
!     int replace;
      // Next rule in the list
      MessageReplaceRule* next;
***************
*** 252,260 ****
      /// Check whether a queue is empty
      bool Empty() { return(this->head == NULL); }
!     /** Push a message onto the queue.  Returns a pointer to the new last
!     element in the queue. UseReserved should only be set true when pushing 
sync
      messages on to the queue. If UseReserved is false then a single message 
slot
      is reserved on the queue for a sync message */
!     MessageQueueElement * Push(Message& msg, bool UseReserved = false);
      /** Pop a message off the queue.
      Pop the head (i.e., the first-inserted) message from the queue.
--- 252,262 ----
      /// Check whether a queue is empty
      bool Empty() { return(this->head == NULL); }
!     /** Push a message onto the queue.  Returns the success state of the Push 
!     operation (true if successful, false otherwise).
!     UseReserved should only be set true when pushing sync
      messages on to the queue. If UseReserved is false then a single message 
slot
      is reserved on the queue for a sync message */
!     bool Push(Message& msg, bool UseReserved = false);
!     
      /** Pop a message off the queue.
      Pop the head (i.e., the first-inserted) message from the queue.
***************
*** 277,281 ****
       * care. */
      void AddReplaceRule(int _host, int _robot, int _interf, int _index,
!                         int _type, int _subtype, bool _replace);
      /** Add a replacement rule to the list.  Use this version if you
       * already have the device address assembled in a player_devaddr_t
--- 279,283 ----
       * care. */
      void AddReplaceRule(int _host, int _robot, int _interf, int _index,
!                         int _type, int _subtype, int _replace);
      /** Add a replacement rule to the list.  Use this version if you
       * already have the device address assembled in a player_devaddr_t
***************
*** 284,291 ****
       * */
      void AddReplaceRule(const player_devaddr_t &device,
!                         int _type, int _subtype, bool _replace);
      /// @brief Check whether a message with the given header should replace
!     /// any existing message of the same signature.
!     bool CheckReplace(player_msghdr_t* hdr);
      /** Wait on this queue.  This method blocks until new data is available
      (as indicated by a call to DataAvailable()). */
--- 286,293 ----
       * */
      void AddReplaceRule(const player_devaddr_t &device,
!                         int _type, int _subtype, int _replace);
      /// @brief Check whether a message with the given header should replace
!     /// any existing message of the same signature, be ignored or accepted.
!     int CheckReplace(player_msghdr_t* hdr);
      /** Wait on this queue.  This method blocks until new data is available
      (as indicated by a call to DataAvailable()). */

Index: message.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/message.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** message.cc  17 Mar 2006 21:22:05 -0000      1.16
--- message.cc  26 Jul 2006 17:14:16 -0000      1.17
***************
*** 163,167 ****
  void
  MessageQueue::AddReplaceRule(int _host, int _robot, int _interf, int _index,
!                              int _type, int _subtype, bool _replace)
  {
    MessageReplaceRule* curr;
--- 163,167 ----
  void
  MessageQueue::AddReplaceRule(int _host, int _robot, int _interf, int _index,
!                              int _type, int _subtype, int _replace)
  {
    MessageReplaceRule* curr;
***************
*** 199,203 ****
  void
  MessageQueue::AddReplaceRule(const player_devaddr_t &device,
!                              int _type, int _subtype, bool _replace)
  {
    this->AddReplaceRule (device.host, device.robot, device.interf, 
device.index,
--- 199,203 ----
  void
  MessageQueue::AddReplaceRule(const player_devaddr_t &device,
!                              int _type, int _subtype, int _replace)
  {
    this->AddReplaceRule (device.host, device.robot, device.interf, 
device.index,
***************
*** 205,209 ****
  }
  
! bool
  MessageQueue::CheckReplace(player_msghdr_t* hdr)
  {
--- 205,209 ----
  }
  
! int
  MessageQueue::CheckReplace(player_msghdr_t* hdr)
  {
***************
*** 222,230 ****
       (hdr->type == PLAYER_MSGTYPE_RESP_NACK) ||
       (hdr->type == PLAYER_MSGTYPE_SYNCH))
!     return(false);
    // Replace data and command according to the this->Replace flag
    else if((hdr->type == PLAYER_MSGTYPE_DATA) ||
            (hdr->type == PLAYER_MSGTYPE_CMD))
!     return(this->Replace);
    else
    {
--- 222,230 ----
       (hdr->type == PLAYER_MSGTYPE_RESP_NACK) ||
       (hdr->type == PLAYER_MSGTYPE_SYNCH))
!     return(PLAYER_PLAYER_MSG_REPLACE_RULE_ACCEPT);
    // Replace data and command according to the this->Replace flag
    else if((hdr->type == PLAYER_MSGTYPE_DATA) ||
            (hdr->type == PLAYER_MSGTYPE_CMD))
!     return(this->Replace ? PLAYER_PLAYER_MSG_REPLACE_RULE_REPLACE : 
PLAYER_PLAYER_MSG_REPLACE_RULE_ACCEPT);
    else
    {
***************
*** 353,357 ****
  }
  
! MessageQueueElement*
  MessageQueue::Push(Message & msg, bool UseReserved)
  {
--- 353,357 ----
  }
  
! bool
  MessageQueue::Push(Message & msg, bool UseReserved)
  {
***************
*** 362,366 ****
    hdr = msg.GetHeader();
    // Should we try to replace an older message of the same signature?
!   if(this->CheckReplace(hdr))
    {
      for(MessageQueueElement* el = this->tail;
--- 362,372 ----
    hdr = msg.GetHeader();
    // Should we try to replace an older message of the same signature?
!   int replaceOp = this->CheckReplace(hdr);
!   if (replaceOp == PLAYER_PLAYER_MSG_REPLACE_RULE_IGNORE)
!   {
!     this->Unlock();
!     return(true);
!   }
!   else if (replaceOp == PLAYER_PLAYER_MSG_REPLACE_RULE_REPLACE)
    {
      for(MessageQueueElement* el = this->tail;
***************
*** 385,389 ****
      if(!this->filter_on)
        this->DataAvailable();
!     return(NULL);
    }
    else
--- 391,395 ----
      if(!this->filter_on)
        this->DataAvailable();
!     return(false);
    }
    else
***************
*** 412,416 ****
      if(!this->filter_on || this->Filter(msg))
        this->DataAvailable();
!     return(newelt);
    }
  }
--- 418,422 ----
      if(!this->filter_on || this->Filter(msg))
        this->DataAvailable();
!     return(true);
    }
  }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to