[Avida-cvs] [Avida2-svn] r145 - trunk/source/bindings/Boost.Python

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Fri Apr 15 00:32:42 PDT 2005


Author: kaben
Date: 2005-04-15 03:32:42 -0400 (Fri, 15 Apr 2005)
New Revision: 145

Added:
   trunk/source/bindings/Boost.Python/change_list.pyste
Modified:
   trunk/source/bindings/Boost.Python/CMakeLists.txt
   trunk/source/bindings/Boost.Python/avida_driver_population.pyste
   trunk/source/bindings/Boost.Python/population.pyste
   trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
   trunk/source/bindings/Boost.Python/py_avida_driver.hh
   trunk/source/bindings/Boost.Python/py_avida_driver.pyste
   trunk/source/bindings/Boost.Python/schedule.pyste
   trunk/source/bindings/Boost.Python/uint.pyste
Log:

* Updated bindings for tracking changed population cells.



Modified: trunk/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- trunk/source/bindings/Boost.Python/CMakeLists.txt	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/CMakeLists.txt	2005-04-15 07:32:42 UTC (rev 145)
@@ -210,6 +210,7 @@
   test_cpu:: # XXX XXX XXX
   tList::${CMAKE_CURRENT_SOURCE_DIR}/string.pyste # XXX XXX XXX
   tVector::
+  change_list::
 )
 SET(PyAvida_Extra_Cpp_Files
   AB.cc

Modified: trunk/source/bindings/Boost.Python/avida_driver_population.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/avida_driver_population.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/avida_driver_population.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,3 +1,5 @@
+
+Include("change_list.hh")
 Include("environment.hh")
 Include("population.hh")
 
@@ -6,4 +8,6 @@
 cAvidaDriver_Population = Class("cAvidaDriver_Population", "avida_driver_population.hh")
 set_policy(cAvidaDriver_Population.GetPopulation, return_internal_reference())
 
+exclude(cAvidaDriver_Population.GetChangeList)
+
 # vim: set ft=python:

Added: trunk/source/bindings/Boost.Python/change_list.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/change_list.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/change_list.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -0,0 +1,14 @@
+
+cChangeList = Class("cChangeList", "change_list.hh")
+class_code(cChangeList, '.def("__len__", &cChangeList__len__)')
+class_code(cChangeList, '.def("__getitem__", &cChangeList__getitem__)')
+declaration_code("""
+inline unsigned int cChangeList__len__(const cChangeList &change_list) {
+  return change_list.GetChangeCount();
+}
+inline unsigned int cChangeList__getitem__(const cChangeList &change_list, unsigned int i) {
+  return change_list.GetChangeAt(i);
+}
+""")
+
+# vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/population.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/population.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/population.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,4 +1,5 @@
 
+Include("change_list.hh")
 Include("environment.hh")
 Include("genebank.hh" )
 Include("inject_genebank.hh")
@@ -22,4 +23,6 @@
 """)
 set_policy(cPopulation.GetEnvironment, return_internal_reference())
 
+exclude(cPopulation.GetChangeList)
+
 # vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,21 +1,25 @@
 
 #include "py_avida_driver.hh"
 
+#include "cpu/hardware_base.hh"
+#include "cpu/hardware_factory.hh"
+#include "main/config.hh"
 #include "main/genebank.hh"
 #include "main/genotype.hh"
+#include "main/organism.hh"
+#include "main/population.hh"
 #include "main/population_cell.hh"
-#include "cpu/hardware_factory.hh"
-#include "main/organism.hh"
-#include "cpu/hardware_base.hh"
+#include "tools/change_list.hh"
 #include "tools/string.hh"
-#include "main/config.hh"
-#include "main/population.hh"
 
 
 #include <iostream>
 
 
 bool pyAvidaDriver::preUpdate(const unsigned int){
+  if (cChangeList *change_list = population->GetChangeList()) {
+    change_list->Reset();
+  }
   GetEvents();
   if(true == done_flag){ return false; }
   // Increment the Update.
@@ -119,11 +123,20 @@
   return false;
 }
 
+cChangeList *pyAvidaDriver::GetChangeList(){
+  return population->GetChangeList();
+}
+
 pyAvidaDriver::pyAvidaDriver(cEnvironment & environment)
 : cAvidaDriver_Population(environment)
 , m_update_mode_function(&pyAvidaDriver::fastUpdate)
 , m_update_stage_function(&pyAvidaDriver::preUpdate)
 , m_step_cell_id(-1)
-{}
+, m_change_list(new cChangeList())
+{
+  population->SetChangeList(m_change_list);
+}
 
-pyAvidaDriver::~pyAvidaDriver(){}
+pyAvidaDriver::~pyAvidaDriver(){
+  delete m_change_list;
+}

Modified: trunk/source/bindings/Boost.Python/py_avida_driver.hh
===================================================================
--- trunk/source/bindings/Boost.Python/py_avida_driver.hh	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/py_avida_driver.hh	2005-04-15 07:32:42 UTC (rev 145)
@@ -8,6 +8,7 @@
 #include "environment.hh"
 #endif
 
+class cChangeList;
 class pyAvidaDriver : public cAvidaDriver_Population {
 protected:
   bool (pyAvidaDriver::*m_update_mode_function)(const unsigned int bite_size);
@@ -21,6 +22,7 @@
   // communicating this to the breakpoint-handling function).
   int m_current_cell_id;
   int m_step_cell_id;
+  cChangeList *m_change_list;
 protected:
   bool preUpdate(const unsigned int);
   bool fastUpdate(const unsigned int bite_size);
@@ -35,6 +37,7 @@
   void setDoneFlag(){ done_flag = true; }
 public:
   bool ProcessSome(unsigned int bite_size){ return (this->*(m_update_stage_function))(bite_size); }
+  cChangeList *GetChangeList();
 };
 
 #endif

Modified: trunk/source/bindings/Boost.Python/py_avida_driver.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/py_avida_driver.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/py_avida_driver.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,6 +1,9 @@
 
+Include("change_list.hh")
+
 Import("avida_driver_population.pyste")
 
 pyAvidaDriver = Class("pyAvidaDriver", "py_avida_driver.hh")
+set_policy(pyAvidaDriver.GetChangeList, return_internal_reference())
 
 # vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/schedule.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/schedule.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/schedule.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,6 +1,9 @@
 
+Include("change_list.hh")
 Include("merit.hh")
 
 cSchedule = Class("cSchedule", "schedule.hh")
 
+exclude(cSchedule.GetChangeList)
+
 # vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/uint.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/uint.pyste	2005-04-15 07:31:46 UTC (rev 144)
+++ trunk/source/bindings/Boost.Python/uint.pyste	2005-04-15 07:32:42 UTC (rev 145)
@@ -1,3 +1,4 @@
+
 cUInt = Class("cUInt", "uint.hh")
 
 # vim: set ft=python:




More information about the Avida-cvs mailing list