[Avida-SVN] r2136 - branches/energy/source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Thu Oct 11 09:24:26 PDT 2007


Author: beckma24
Date: 2007-10-11 12:24:25 -0400 (Thu, 11 Oct 2007)
New Revision: 2136

Modified:
   branches/energy/source/main/cOrganism.cc
   branches/energy/source/main/cOrganism.h
   branches/energy/source/main/cPopulationInterface.cc
Log:
Modified Organism:ReceiveMessage to return false on a message collision, and true otherwise.  This value is fed back to cOrganism:SendMessage and determines if the message was succesfully sent/received

Modified: branches/energy/source/main/cOrganism.cc
===================================================================
--- branches/energy/source/main/cOrganism.cc	2007-10-11 13:58:56 UTC (rev 2135)
+++ branches/energy/source/main/cOrganism.cc	2007-10-11 16:24:25 UTC (rev 2136)
@@ -646,7 +646,7 @@
 }
 
 
-void cOrganism::ReceiveMessage(cOrgMessage& msg)
+bool cOrganism::ReceiveMessage(cOrgMessage& msg)
 {
   InitMessaging();
   
@@ -662,11 +662,12 @@
     msg.SetReceiver(this);
     m_msg->received.push_back(msg);
     m_world->GetStats().IncMsgReceived();
-  } else {
-    // collision
-    m_msg->received.pop_back();
-    m_world->GetStats().IncMsgCollision();
+    return true;
   }
+  // else collision
+  m_msg->received.pop_back();
+  m_world->GetStats().IncMsgCollision();
+  return false;
 }
 
 

Modified: branches/energy/source/main/cOrganism.h
===================================================================
--- branches/energy/source/main/cOrganism.h	2007-10-11 13:58:56 UTC (rev 2135)
+++ branches/energy/source/main/cOrganism.h	2007-10-11 16:24:25 UTC (rev 2136)
@@ -320,7 +320,7 @@
   //! Called when this organism attempts to send a message.
   bool SendMessage(cAvidaContext& ctx, cOrgMessage& msg);
   //! Called when this organism has been sent a message.
-  void ReceiveMessage(cOrgMessage& msg);
+  bool ReceiveMessage(cOrgMessage& msg);
   //! Called when this organism attempts to move a received message into its CPU.
   const cOrgMessage* RetrieveMessage();
   //! Similar to RetrieveMessage, but TX must be complete for message to be available

Modified: branches/energy/source/main/cPopulationInterface.cc
===================================================================
--- branches/energy/source/main/cPopulationInterface.cc	2007-10-11 13:58:56 UTC (rev 2135)
+++ branches/energy/source/main/cPopulationInterface.cc	2007-10-11 16:24:25 UTC (rev 2136)
@@ -251,6 +251,5 @@
   }
   cOrganism* recvr = rcell->GetOrganism();
   assert(recvr != NULL);
-  recvr->ReceiveMessage(msg);
-  return true;
+  return recvr->ReceiveMessage(msg);
 }




More information about the Avida-cvs mailing list