[Avida-SVN] r2911 - in branches/collect: Avida.xcodeproj source/actions source/analyze source/drivers source/main source/platform source/script source/targets/avida-viewer source/targets/viewer-text source/tools

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Sat Nov 1 16:23:53 PDT 2008


Author: blwalker
Date: 2008-11-01 19:23:53 -0400 (Sat, 01 Nov 2008)
New Revision: 2911

Added:
   branches/collect/source/drivers/cDMObject.h
   branches/collect/source/drivers/tDMSingleton.h
   branches/collect/source/tools/tDataCommandManager.h
Modified:
   branches/collect/Avida.xcodeproj/project.pbxproj
   branches/collect/source/actions/cActionLibrary.cc
   branches/collect/source/actions/cActionLibrary.h
   branches/collect/source/analyze/cAnalyze.cc
   branches/collect/source/analyze/cAnalyzeCommandAction.h
   branches/collect/source/analyze/cAnalyzeGenotype.cc
   branches/collect/source/analyze/cAnalyzeGenotype.h
   branches/collect/source/drivers/cAvidaDriver.h
   branches/collect/source/drivers/cDefaultAnalyzeDriver.cc
   branches/collect/source/drivers/cDefaultAnalyzeDriver.h
   branches/collect/source/drivers/cDefaultRunDriver.cc
   branches/collect/source/drivers/cDefaultRunDriver.h
   branches/collect/source/drivers/cDriverManager.cc
   branches/collect/source/drivers/cDriverManager.h
   branches/collect/source/drivers/cDriverStatusConduit.h
   branches/collect/source/drivers/cFallbackWorldDriver.h
   branches/collect/source/drivers/cWorldDriver.h
   branches/collect/source/main/avida.cc
   branches/collect/source/main/avida.h
   branches/collect/source/main/cEventList.cc
   branches/collect/source/main/cWorld.cc
   branches/collect/source/main/cWorld.h
   branches/collect/source/platform/PlatformExpert.cc
   branches/collect/source/script/ASAnalyzeLib.cc
   branches/collect/source/script/ASAvidaLib.cc
   branches/collect/source/script/ASAvidaNativeObjects.h
   branches/collect/source/targets/avida-viewer/cTextViewerAnalyzeDriver.cc
   branches/collect/source/targets/avida-viewer/cTextViewerDriver.cc
   branches/collect/source/targets/viewer-text/cDriver_TextViewer.cc
Log:

Porting r2906:2909 from development branch to collect branch.  Fixed tiny change-of-variable-name issue introduced in 2907.


Modified: branches/collect/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/collect/Avida.xcodeproj/project.pbxproj	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/Avida.xcodeproj/project.pbxproj	2008-11-01 23:23:53 UTC (rev 2911)
@@ -745,6 +745,9 @@
 		70B1A7590B7E431F00067486 /* experimental.org */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = experimental.org; sourceTree = "<group>"; };
 		70B3984E0947B29D0018F09D /* tManagedPointerArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tManagedPointerArray.h; sourceTree = "<group>"; };
 		70B6514C0BEA6FAD002472ED /* unit-tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "unit-tests"; sourceTree = BUILT_PRODUCTS_DIR; };
+		70B984220EBB5B7F00A828B1 /* tDMSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tDMSingleton.h; sourceTree = "<group>"; };
+		70B9842B0EBB5D4C00A828B1 /* cDMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cDMObject.h; sourceTree = "<group>"; };
+		70B984B40EBB71B500A828B1 /* tDataCommandManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tDataCommandManager.h; sourceTree = "<group>"; };
 		70BB2A290E9FA12F008269D2 /* ASAvidaLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASAvidaLib.h; sourceTree = "<group>"; };
 		70BB2A2A0E9FA12F008269D2 /* ASAvidaLib.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASAvidaLib.cc; sourceTree = "<group>"; };
 		70BB2ABF0EA4F896008269D2 /* tThreadSpecific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tThreadSpecific.h; sourceTree = "<group>"; };
@@ -984,6 +987,8 @@
 				701D93E6094CBF71008B845F /* cDefaultAnalyzeDriver.h */,
 				701D93E7094CBF71008B845F /* cDefaultAnalyzeDriver.cc */,
 				70BB2AC20EA4FF25008269D2 /* cDriverStatusConduit.h */,
+				70B984220EBB5B7F00A828B1 /* tDMSingleton.h */,
+				70B9842B0EBB5D4C00A828B1 /* cDMObject.h */,
 			);
 			path = drivers;
 			sourceTree = "<group>";
@@ -1638,6 +1643,7 @@
 				70F9FD990C4E89C40083B788 /* tAutoRelease.h */,
 				70EFD65E0D975B5E00FAD32A /* cConstBurstSchedule.h */,
 				70EFD65F0D975B5E00FAD32A /* cConstBurstSchedule.cc */,
+				70B984B40EBB71B500A828B1 /* tDataCommandManager.h */,
 			);
 			path = tools;
 			sourceTree = "<group>";

Modified: branches/collect/source/actions/cActionLibrary.cc
===================================================================
--- branches/collect/source/actions/cActionLibrary.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/actions/cActionLibrary.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -31,8 +31,10 @@
 #include "PrintActions.h"
 #include "SaveLoadActions.h"
 
+#include "tDMSingleton.h"
 
-cActionLibrary* cActionLibrary::ConstructDefaultActionLibrary()
+
+cActionLibrary* cActionLibrary::buildDefaultActionLibrary()
 {
   cActionLibrary* actlib = new cActionLibrary();
 
@@ -46,6 +48,18 @@
   return actlib;
 }
 
+
+void cActionLibrary::Initialize()
+{
+  tDMSingleton<cActionLibrary>::Initialize(&cActionLibrary::buildDefaultActionLibrary);
+}
+
+cActionLibrary& cActionLibrary::GetInstance()
+{
+  return tDMSingleton<cActionLibrary>::GetInstance();
+}
+
+
 const cString cActionLibrary::DescribeAll() const
 {
   tList<cString> names;

Modified: branches/collect/source/actions/cActionLibrary.h
===================================================================
--- branches/collect/source/actions/cActionLibrary.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/actions/cActionLibrary.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -52,10 +52,18 @@
   
   tObjectFactoryNoCase<cAction* (cWorld*, const cString&)> m_factory;
   tDictionary<ClassDescFunction> m_desc_funcs;
+  
+  static cActionLibrary* buildDefaultActionLibrary();
 
-public:
   cActionLibrary() { ; }
+
   
+public:
+  ~cActionLibrary() { ; }
+  
+  static void Initialize();
+  static cActionLibrary& GetInstance();
+  
   template<typename ClassType> bool Register(const cString& key)
   {
     ClassDescFunction func;
@@ -79,8 +87,6 @@
     return "(Not Available)";
   }  
   const cString DescribeAll() const;
-  
-  static cActionLibrary* ConstructDefaultActionLibrary();
 };
 
 

Modified: branches/collect/source/analyze/cAnalyze.cc
===================================================================
--- branches/collect/source/analyze/cAnalyze.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/analyze/cAnalyze.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -42,8 +42,8 @@
 #include "cAnalyzeGenotype.h"
 #include "cAnalyzeTreeStats_CumulativeStemminess.h"
 #include "cAnalyzeTreeStats_Gamma.h"
-#include "tAnalyzeJob.h"
 #include "cAvidaContext.h"
+#include "cCPUTestInfo.h"
 #include "cDataFile.h"
 #include "cEnvironment.h"
 #include "cFitnessMatrix.h"
@@ -61,19 +61,20 @@
 #include "cProbSchedule.h"
 #include "cReaction.h"
 #include "cReactionProcess.h"
+#include "cResource.h"
 #include "cResourceHistory.h"
 #include "cSchedule.h"
 #include "cSpecies.h"
 #include "cStringIterator.h"
+#include "cTestCPU.h"
+#include "cWorld.h"
+#include "cWorldDriver.h"
+#include "tAnalyzeJob.h"
+#include "tDataCommandManager.h"
 #include "tDataEntry.h"
 #include "tDataEntryCommand.h"
+#include "tHashTable.h"
 #include "tMatrix.h"
-#include "cTestCPU.h"
-#include "cCPUTestInfo.h"
-#include "cResource.h"
-#include "tHashTable.h"
-#include "cWorld.h"
-#include "cWorldDriver.h"
 
 #include "defs.h"
 
@@ -912,7 +913,7 @@
   // Construct a linked list of data types that can be loaded...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, input_file.GetFormat(), output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(input_file.GetFormat(), output_list);
   bool id_inc = input_file.GetFormat().HasString("id");
   
   // Setup the genome...
@@ -963,7 +964,7 @@
   cString test_value = cur_string.PopWord();
   
   // Get the dynamic command to look up the stat we need.
-  tDataEntryCommand<cAnalyzeGenotype> * stat_command = cAnalyzeGenotype::GetDataCommand(m_world, stat_name);
+  tDataEntryCommand<cAnalyzeGenotype>* stat_command = cAnalyzeGenotype::GetDataCommandManager().GetDataCommand(stat_name);
   
   
   // Check for various possible errors before moving on...
@@ -1915,7 +1916,7 @@
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, cur_string, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(cur_string, output_list);
   
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
@@ -1961,7 +1962,7 @@
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, cur_string, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(cur_string, output_list);
   
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
@@ -2150,7 +2151,7 @@
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, cur_string, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(cur_string, output_list);
   
   // check if file is already in use.
   bool file_active = m_world->GetDataFileManager().IsOpen(filename);
@@ -2179,7 +2180,7 @@
   else cout << "Detailing Batches..." << endl;
   
   // Find its associated command...
-  tDataEntryCommand<cAnalyzeGenotype>* cur_command = cAnalyzeGenotype::GetDataCommand(m_world, keyword);
+  tDataEntryCommand<cAnalyzeGenotype>* cur_command = cAnalyzeGenotype::GetDataCommandManager().GetDataCommand(keyword);
   if (!cur_command) {
     cout << "error: no data entry, unable to detail batches" << endl;
     return;
@@ -2282,7 +2283,7 @@
   // Construct a linked list of details needed...
   tList<tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator<tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, cStringList(cur_string), output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(cStringList(cur_string), output_list);
   
   
   // Setup the file...
@@ -2381,7 +2382,7 @@
   // Construct a linked list of details needed...
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, cur_string, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(cur_string, output_list);
   
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
@@ -4645,7 +4646,7 @@
   msg.Set("There are %d column args.", arg_list.GetSize());
   m_world->GetDriver().NotifyComment(msg);
   
-  cAnalyzeGenotype::LoadDataCommandList(m_world, arg_list, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(arg_list, output_list);
   
   m_world->GetDriver().NotifyComment("Args are loaded.");
   
@@ -4905,7 +4906,7 @@
   
   cout << "There are " << arg_list.GetSize() << " column args." << endl;
   
-  cAnalyzeGenotype::LoadDataCommandList(m_world, arg_list, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(arg_list, output_list);
   
   cout << "Args are loaded." << endl;
   
@@ -5249,7 +5250,7 @@
   tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
   tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
   cStringList arg_list(cur_string);
-  cAnalyzeGenotype::LoadDataCommandList(m_world, arg_list, output_list);
+  cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(arg_list, output_list);
   const int num_traits = output_list.GetSize();
   
   // Setup the map_inst_set with the NULL instruction
@@ -9230,7 +9231,7 @@
   }
   cAnalyzeCommandDefBase* command_def = lib_it.Get();
   
-  if (command_def == NULL && m_world->GetActionLibrary().Supports(name)) {
+  if (command_def == NULL && cActionLibrary::GetInstance().Supports(name)) {
     command_def = new cAnalyzeCommandAction(name, m_world);
     command_lib.PushRear(command_def);
   }

Modified: branches/collect/source/analyze/cAnalyzeCommandAction.h
===================================================================
--- branches/collect/source/analyze/cAnalyzeCommandAction.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/analyze/cAnalyzeCommandAction.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -53,7 +53,7 @@
   
   void Run(cAnalyze* analyze, const cString& args, cAnalyzeCommand& command) const
   {
-    cAction* action = m_world->GetActionLibrary().Create(name, m_world, args);
+    cAction* action = cActionLibrary::GetInstance().Create(name, m_world, args);
     cAvidaContext& ctx = m_world->GetDefaultContext();
     action->Process(ctx);
   }

Modified: branches/collect/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/analyze/cAnalyzeGenotype.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -44,8 +44,8 @@
 
 #include "tArray.h"
 #include "tAutoRelease.h"
-#include "tDataEntry.h"
-#include "tDataEntryCommand.h"
+#include "tDataCommandManager.h"
+#include "tDMSingleton.h"w
 
 
 #include <cmath>
@@ -204,9 +204,16 @@
 }
 
 
-tDictionary<tDataEntry<cAnalyzeGenotype>*>* cAnalyzeGenotype::BuildDEDict(cWorld* world)
+void cAnalyzeGenotype::Initialize()
 {
-  tDictionary<tDataEntry<cAnalyzeGenotype>*>* dedict = new tDictionary<tDataEntry<cAnalyzeGenotype>*>;
+  tDMSingleton<tDataCommandManager<cAnalyzeGenotype> >::Initialize(&cAnalyzeGenotype::buildDataCommandManager);
+}
+
+
+tDataCommandManager<cAnalyzeGenotype>* cAnalyzeGenotype::buildDataCommandManager()
+{
+  tDataCommandManager<cAnalyzeGenotype>* dcm = new tDataCommandManager<cAnalyzeGenotype>;
+  
   // A basic macro to link a keyword to a description and Get and Set methods in cAnalyzeGenotype.
 #define ADD_GDATA(TYPE, KEYWORD, DESC, GET, SET, COMP, NSTR, HSTR)                                \
   {                                                                                               \
@@ -216,7 +223,7 @@
     cString html_str = "align=center";                                                            \
     if (hstr_str != "0") html_str = HSTR;                                                         \
                                                                                                   \
-    dedict->Add(KEYWORD, new tDataEntryOfType<cAnalyzeGenotype, TYPE>                              \
+    dcm->Add(KEYWORD, new tDataEntryOfType<cAnalyzeGenotype, TYPE>                              \
       (KEYWORD, DESC, &cAnalyzeGenotype::GET, &cAnalyzeGenotype::SET, COMP, null_str, html_str)); \
   }
 
@@ -296,7 +303,7 @@
   ADD_GDATA(cString (), "link.tasksites", "Phenotype Map",              GetMapLink,      SetNULL, 0, 0,       0);
   ADD_GDATA(cString (), "html.sequence",  "Genome Sequence",            GetHTMLSequence, SetNULL, 0, "(N/A)", "");
   
-  dedict->Add("inst", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
+  dcm->Add("inst", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
               ("inst", &cAnalyzeGenotype::DescInstExe, &cAnalyzeGenotype::GetInstExecutedCount));
   
   // coarse-grained task stats
@@ -304,10 +311,10 @@
   ADD_GDATA(int (), 		"total_task_performance_count", "Total Tasks Performed",	GetTotalTaskPerformanceCount, SetNULL, 1, 0, 0);
   
   
-  dedict->Add("task", new tDataEntryOfType<cAnalyzeGenotype, int (int, const cStringList&)>
-              ("task", &cAnalyzeGenotype::DescTask, &cAnalyzeGenotype::GetTaskCount, 5));
-  dedict->Add("env_input", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
-              ("env_input", &cAnalyzeGenotype::DescEnvInput, &cAnalyzeGenotype::GetEnvInput));
+  dcm->Add("task", new tDataEntryOfType<cAnalyzeGenotype, int (int, const cStringList&)>
+           ("task", &cAnalyzeGenotype::DescTask, &cAnalyzeGenotype::GetTaskCount, 5));
+  dcm->Add("env_input", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
+           ("env_input", &cAnalyzeGenotype::DescEnvInput, &cAnalyzeGenotype::GetEnvInput));
     
   // The remaining values should actually go in a seperate list called
   // "population_data_list", but for the moment we're going to put them
@@ -319,61 +326,17 @@
   ADD_GDATA(int (),     "dom_id",       "Dominant Genotype ID",            GetID,         SetID,         0, 0, 0);
   ADD_GDATA(cString (), "dom_sequence", "Dominant Genotype Sequence",      GetSequence,   SetSequence,   0, "(N/A)", "");
   
-  return dedict;
   
+  return dcm;
 #undef ADD_GDATA
 }
 
-void cAnalyzeGenotype::DestroyDEDict(tDictionary<tDataEntry<cAnalyzeGenotype>*>* dedict)
+const tDataCommandManager<cAnalyzeGenotype>& cAnalyzeGenotype::GetDataCommandManager()
 {
-  tArray<tDataEntry<cAnalyzeGenotype>*> entries;
-  dedict->GetValues(entries);
-  for (int i = 0; i < entries.GetSize(); i++) delete entries[i];
-  delete dedict;
+  return tDMSingleton<tDataCommandManager<cAnalyzeGenotype> >::GetInstance();
 }
 
 
-
-// Find a data entry bassed on a keyword
-tDataEntryCommand<cAnalyzeGenotype>* cAnalyzeGenotype::GetDataCommand(cWorld* world, const cString& cmd) 
-{
-  cString arg_list = cmd;
-  cString idx = arg_list.Pop(':');
-  cString entry_name = idx.Pop('.');
-  
-  tDataEntry<cAnalyzeGenotype>* data_entry;
-  if (world->GetGenotypeDEDict().Find(entry_name, data_entry)) {
-    return new tDataEntryCommand<cAnalyzeGenotype>(data_entry, idx, arg_list);
-  }
-  
-  cDriverManager::Status().NotifyWarning(cStringUtil::Stringf("data entry '%s' not found, best match is '%s'", *entry_name,
-                                                              *(world->GetGenotypeDEDict().NearMatch(entry_name))));
-  
-  return NULL;
-}
-
-
-// Pass in the arguments for a command and fill out the entries in list format....
-void cAnalyzeGenotype::LoadDataCommandList(cWorld* world, cStringList arg_list,
-                                    tList<tDataEntryCommand<cAnalyzeGenotype> >& output_list)
-{
-  if (arg_list.GetSize() == 0) {
-    // If no args were given, load all of the stats.
-    // @TODO - handle indexed items...  under this scheme only the first task and env_input value will be output    
-
-    tArray<tDataEntry<cAnalyzeGenotype>*> data_entries;
-    world->GetGenotypeDEDict().GetValues(data_entries);
-    for (int i = 0; i < data_entries.GetSize(); i++)
-      output_list.PushRear(new tDataEntryCommand<cAnalyzeGenotype>(data_entries[i]));
-  } else {
-    while (arg_list.GetSize() != 0) {
-      tDataEntryCommand<cAnalyzeGenotype>* cur_command = GetDataCommand(world, arg_list.Pop());
-      if (cur_command) output_list.PushRear(cur_command);
-    }
-  }
-}
-
-
 cString cAnalyzeGenotype::DescTask(int task_id) const
 {
   if (task_id > task_counts.GetSize()) return "";

Modified: branches/collect/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/analyze/cAnalyzeGenotype.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -65,9 +65,7 @@
 class cInstSet;
 class cTestCPU;
 class cWorld;
-template<class T> class tDataEntry;
-template<class T> class tDataEntryCommand;
-template<class T> class tDictionary;
+template<class T> class tDataCommandManager;
 
 
 class cAnalyzeGenotype;
@@ -230,6 +228,8 @@
   void CheckLand() const;
   void CheckPhenPlast() const;
   void SummarizePhenotypicPlasticity(const cPhenPlastGenotype& pp) const;
+  
+  static tDataCommandManager<cAnalyzeGenotype>* buildDataCommandManager();
 
 
 
@@ -239,11 +239,8 @@
   cAnalyzeGenotype(const cAnalyzeGenotype & _gen);
   ~cAnalyzeGenotype();
   
-  static tDictionary<tDataEntry<cAnalyzeGenotype>*>* BuildDEDict(cWorld* world);
-  static void DestroyDEDict(tDictionary<tDataEntry<cAnalyzeGenotype>*>* dedict);
-  
-  static tDataEntryCommand<cAnalyzeGenotype>* GetDataCommand(cWorld* world, const cString& cmd);
-  static void LoadDataCommandList(cWorld* world, cStringList arg_list, tList<tDataEntryCommand<cAnalyzeGenotype> >& output_list);
+  static void Initialize();
+  static const tDataCommandManager<cAnalyzeGenotype>& GetDataCommandManager();
 
   void Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info = NULL, cAnalyzeGenotype* parent_genotype = NULL, int num_trials = 1);
   void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);

Modified: branches/collect/source/drivers/cAvidaDriver.h
===================================================================
--- branches/collect/source/drivers/cAvidaDriver.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cAvidaDriver.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,11 +25,14 @@
 #ifndef cAvidaDriver_h
 #define cAvidaDriver_h
 
+#include "cDMObject.h"
+
+
 // This class is an abstract base class from which all driver classes
 // in Avida descend.  cAvidaDriver objects are friends with cWorld,
 // allowing them to register cWorldDriver's with an instance of cWorld.
 
-class cAvidaDriver
+class cAvidaDriver : public virtual cDMObject
 {
 private:
   cAvidaDriver(const cAvidaDriver&); // @not_implemented

Copied: branches/collect/source/drivers/cDMObject.h (from rev 2909, development/source/drivers/cDMObject.h)
===================================================================
--- branches/collect/source/drivers/cDMObject.h	                        (rev 0)
+++ branches/collect/source/drivers/cDMObject.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -0,0 +1,35 @@
+/*
+ *  cDMObject.h
+ *  Avida
+ *
+ *  Created by David on 10/31/08.
+ *  Copyright 2008 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef cDMObject_h
+#define cDMObject_h
+
+class cDMObject
+{
+public:
+  virtual ~cDMObject() { ; }
+};
+
+
+#endif

Modified: branches/collect/source/drivers/cDefaultAnalyzeDriver.cc
===================================================================
--- branches/collect/source/drivers/cDefaultAnalyzeDriver.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDefaultAnalyzeDriver.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -37,13 +37,13 @@
 cDefaultAnalyzeDriver::cDefaultAnalyzeDriver(cWorld* world, bool inter)
   : m_world(world), m_interactive(inter)
 {
-  cDriverManager::Register(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Register(this);
   world->SetDriver(this);
 }
 
 cDefaultAnalyzeDriver::~cDefaultAnalyzeDriver()
 {
-  cDriverManager::Unregister(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Unregister(this);
   delete m_world;
 }
 

Modified: branches/collect/source/drivers/cDefaultAnalyzeDriver.h
===================================================================
--- branches/collect/source/drivers/cDefaultAnalyzeDriver.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDefaultAnalyzeDriver.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,12 +25,8 @@
 #ifndef cDefaultAnalyzeDriver_h
 #define cDefaultAnalyzeDriver_h
 
-#ifndef cAvidaDriver_h
 #include "cAvidaDriver.h"
-#endif
-#ifndef cWorldDriver_h
 #include "cWorldDriver.h"
-#endif
 
 #if USE_tMemTrack
 # ifndef tMemTrack_h

Modified: branches/collect/source/drivers/cDefaultRunDriver.cc
===================================================================
--- branches/collect/source/drivers/cDefaultRunDriver.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDefaultRunDriver.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -48,7 +48,7 @@
 cDefaultRunDriver::cDefaultRunDriver(cWorld* world) : m_world(world), m_done(false), 
       m_fastforward(false),m_last_generation(0),  m_generation_same_update_count(0) 
 {
-  cDriverManager::Register(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Register(this);
   world->SetDriver(this);
   
   // Save this config variable
@@ -58,7 +58,7 @@
 
 cDefaultRunDriver::~cDefaultRunDriver()
 {
-  cDriverManager::Unregister(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Unregister(this);
   delete m_world;
 }
 

Modified: branches/collect/source/drivers/cDefaultRunDriver.h
===================================================================
--- branches/collect/source/drivers/cDefaultRunDriver.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDefaultRunDriver.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,16 +25,13 @@
 #ifndef cDefaultRunDriver_h
 #define cDefaultRunDriver_h
 
-#ifndef cAvidaDriver_h
 #include "cAvidaDriver.h"
-#endif
-#ifndef cWorldDriver_h
 #include "cWorldDriver.h"
-#endif
 
 class cString;
 class cWorld;
 
+
 class cDefaultRunDriver : public cAvidaDriver, public cWorldDriver
 {
 private:

Modified: branches/collect/source/drivers/cDriverManager.cc
===================================================================
--- branches/collect/source/drivers/cDriverManager.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDriverManager.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -24,41 +24,25 @@
 
 #include "cDriverManager.h"
 
-#include "cActionLibrary.h"
-#include "cAvidaDriver.h"
 #include "cDriverStatusConduit.h"
-#include "cWorldDriver.h"
+#include "cDMObject.h"
 
 #include <cassert>
 #include <cstdlib>
 
 
-cDriverManager* cDriverManager::m_dm = NULL;
+cDriverManager* cDriverManager::s_dm = NULL;
 
-cDriverManager::cDriverManager()
-{
-  m_actlib = cActionLibrary::ConstructDefaultActionLibrary();
-}
-
 cDriverManager::~cDriverManager()
 {
-  cAvidaDriver* adrv;
-  while ((adrv = m_adrvs.Pop())) {
-    delete adrv;
-  }
-  
-  cWorldDriver* wdrv;
-  while ((wdrv = m_wdrvs.Pop())) {
-    delete wdrv;
-  }
-  
-  delete m_actlib;
+  cDMObject* obj;
+  while ((obj = m_objs.Pop())) delete obj;
 }
 
 void cDriverManager::Initialize()
 {
-  if (m_dm == NULL) {
-    m_dm = new cDriverManager();
+  if (s_dm == NULL) {
+    s_dm = new cDriverManager();
     if (atexit(cDriverManager::Destroy)) {
       // Failed to register with atexit, this is bad, very bad.
       exit(-1);
@@ -68,59 +52,37 @@
 
 void cDriverManager::Destroy()
 {
-  delete m_dm;
+  delete s_dm;
 }
 
-void cDriverManager::Register(cAvidaDriver* drv)
+void cDriverManager::Register(cDMObject* obj)
 {
-  assert(m_dm);
-  m_dm->m_mutex.Lock();
-  m_dm->m_adrvs.Push(drv);
-  m_dm->m_mutex.Unlock();
+  assert(s_dm);
+  s_dm->m_mutex.Lock();
+  s_dm->m_objs.Push(obj);
+  s_dm->m_mutex.Unlock();
 }
 
-void cDriverManager::Register(cWorldDriver* drv)
+void cDriverManager::Unregister(cDMObject* obj)
 {
-  assert(m_dm);
-  m_dm->m_mutex.Lock();
-  m_dm->m_wdrvs.Push(drv);
-  m_dm->m_mutex.Unlock();
+  assert(s_dm);
+  s_dm->m_mutex.Lock();
+  s_dm->m_objs.Remove(obj);
+  s_dm->m_mutex.Unlock();
 }
 
-void cDriverManager::Unregister(cAvidaDriver* drv)
-{
-  assert(m_dm);
-  m_dm->m_mutex.Lock();
-  m_dm->m_adrvs.Remove(drv);
-  m_dm->m_mutex.Unlock();
-}
-
-void cDriverManager::Unregister(cWorldDriver* drv)
-{
-  assert(m_dm);
-  m_dm->m_mutex.Lock();
-  m_dm->m_wdrvs.Remove(drv);
-  m_dm->m_mutex.Unlock();
-}
-
 cDriverStatusConduit& cDriverManager::Status()
 {
-  cDriverStatusConduit* conduit = m_dm->m_conduit.Get();
+  cDriverStatusConduit* conduit = s_dm->m_conduit.Get();
   if (!conduit) {
     conduit = new cDriverStatusConduit;
-    m_dm->m_conduit.Set(conduit);
+    s_dm->m_conduit.Set(conduit);
   }
   return *conduit;
 }
 
 void cDriverManager::SetConduit(cDriverStatusConduit* conduit)
 {
-  m_dm->m_conduit.Set(conduit);
+  assert(s_dm);
+  s_dm->m_conduit.Set(conduit);
 }
-
-
-cActionLibrary* cDriverManager::GetActionLibrary()
-{
-  assert(m_dm);
-  return m_dm->m_actlib;
-}

Modified: branches/collect/source/drivers/cDriverManager.h
===================================================================
--- branches/collect/source/drivers/cDriverManager.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDriverManager.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,36 +25,25 @@
 #ifndef cDriverManager_h
 #define cDriverManager_h
 
-#ifndef tList_h
 #include "tList.h"
-#endif
-#ifndef cMutex_h
 #include "cMutex.h"
-#endif
-#ifndef tThreadSpecific_h
+#include "cDriverStatusConduit.h"
 #include "tThreadSpecific.h"
-#endif
 
-class cActionLibrary;
-class cAvidaDriver;
-class cDriverStatusConduit;
-class cWorldDriver;
+class cDMObject;
 
 
 class cDriverManager
 {
 private:
-  static cDriverManager* m_dm;
+  static cDriverManager* s_dm;
   
-  tList<cAvidaDriver> m_adrvs;
-  tList<cWorldDriver> m_wdrvs;
+  tList<cDMObject> m_objs;
   
   cMutex m_mutex;
-  cActionLibrary* m_actlib;
-  
   tThreadSpecific<cDriverStatusConduit> m_conduit;
   
-  cDriverManager();
+  cDriverManager() { ; }
   ~cDriverManager();
 
   cDriverManager(const cDriverManager&); // @not_implemented
@@ -65,16 +54,11 @@
 public:
   static void Initialize(); // initialize static driver manager.  This method is NOT thread-safe.
 
-  static void Register(cAvidaDriver* drv);
-  static void Register(cWorldDriver* drv);
-
-  static void Unregister(cAvidaDriver* drv);
-  static void Unregister(cWorldDriver* drv);
+  static void Register(cDMObject* obj);
+  static void Unregister(cDMObject* obj);
   
   static cDriverStatusConduit& Status();
   static void SetConduit(cDriverStatusConduit* conduit);
-    
-  static cActionLibrary* GetActionLibrary();
 };
 
 

Modified: branches/collect/source/drivers/cDriverStatusConduit.h
===================================================================
--- branches/collect/source/drivers/cDriverStatusConduit.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cDriverStatusConduit.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,9 +25,9 @@
 #ifndef cDriverStatusConduit_h
 #define cDriverStatusConduit_h
 
-
 class cString;
 
+
 class cDriverStatusConduit
 {
 private:

Modified: branches/collect/source/drivers/cFallbackWorldDriver.h
===================================================================
--- branches/collect/source/drivers/cFallbackWorldDriver.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cFallbackWorldDriver.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,13 +25,10 @@
 #ifndef cFallbackWorldDriver_h
 #define cFallbackWorldDriver_h
 
-#ifndef cDriverManager_h
 #include "cDriverManager.h"
-#endif
-#ifndef cWorldDriver_h
 #include "cWorldDriver.h"
-#endif
 
+
 class cFallbackWorldDriver : public cWorldDriver
 {
 private:

Modified: branches/collect/source/drivers/cWorldDriver.h
===================================================================
--- branches/collect/source/drivers/cWorldDriver.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/drivers/cWorldDriver.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -25,24 +25,19 @@
 #ifndef cWorldDriver_h
 #define cWorldDriver_h
 
-// This class is an abstract base class that is used by actions within
-// a cWorld to notify its driver of various states and conditions.
+#include "cDMObject.h"
 
-#if USE_tMemTrack
-# ifndef tMemTrack_h
-#  include "tMemTrack.h"
-# endif
-#endif
-
 #include <iostream>
 
 class cString;
 
-class cWorldDriver
+
+// This class is an abstract base class that is used by actions within
+// a cWorld to notify its driver of various states and conditions.
+
+
+class cWorldDriver : public virtual cDMObject
 {
-#if USE_tMemTrack
-  tMemTrack<cWorldDriver> mt;
-#endif
 private:
   cWorldDriver(const cWorldDriver&); // @not_implemented
   cWorldDriver& operator=(const cWorldDriver&); // @not_implemented

Copied: branches/collect/source/drivers/tDMSingleton.h (from rev 2909, development/source/drivers/tDMSingleton.h)
===================================================================
--- branches/collect/source/drivers/tDMSingleton.h	                        (rev 0)
+++ branches/collect/source/drivers/tDMSingleton.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -0,0 +1,107 @@
+/*
+ *  tDMSingleton.h
+ *  Avida
+ *
+ *  Created by David on 10/31/08.
+ *  Copyright 2008 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef tDMSingleton_h
+#define tDMSingleton_h
+
+#include "cDMObject.h"
+#include "cDriverManager.h"
+#include "cMutex.h"
+
+
+template<typename T> class tDMSingleton : public cDMObject
+{
+private:
+  static tDMSingleton* s_dms;
+  
+  T* m_object;
+  
+  
+  tDMSingleton(T* object) : m_object(object) { ; }
+  
+  tDMSingleton(); // @not_implemented
+  tDMSingleton(const tDMSingleton&); // @not_implemented
+  tDMSingleton& operator=(const tDMSingleton&); // @not_implemented
+  
+  
+public:
+  ~tDMSingleton() { delete m_object; }
+
+  static void Initialize(T* (construct)())
+  {
+    if (!s_dms) {
+      s_dms = new tDMSingleton((*construct)());
+      cDriverManager::Register(s_dms);
+    }
+  }
+
+  static T& GetInstance() { return *s_dms->m_object; }
+};
+
+template<typename T> tDMSingleton<T>* tDMSingleton<T>::s_dms = NULL;
+
+
+template<typename T> class tLazyDMSingleton : public cDMObject
+{
+private:
+  static tLazyDMSingleton* s_dms;
+  
+  cMutex m_mutex;
+  T* (*m_construct)();
+  T* m_object;
+  
+  
+  tLazyDMSingleton(T* (*construct)()) : m_object(NULL), m_construct(construct) { ; }
+  
+  tLazyDMSingleton(); // @not_implemented
+  tLazyDMSingleton(const tLazyDMSingleton&); // @not_implemented
+  tLazyDMSingleton& operator=(const tLazyDMSingleton&); // @not_implemented
+  
+  
+public:
+  ~tLazyDMSingleton() { delete m_object; }
+  
+  static void Initialize(T* (*construct)())
+  {
+    if (!s_dms) {
+      s_dms = new tLazyDMSingleton(construct);
+      cDriverManager::Register(s_dms);
+    }
+  }
+
+  static T& GetInstance()
+  {
+    cMutexAutoLock lock(s_dms->m_mutex);
+    
+    if (!s_dms->m_object) {
+      s_dms->m_object = (*s_dms->m_construct)();
+    }
+    
+    return *s_dms->m_object;
+  }
+};
+
+template<typename T> tLazyDMSingleton<T>* tLazyDMSingleton<T>::s_dms = NULL;
+
+#endif

Modified: branches/collect/source/main/avida.cc
===================================================================
--- branches/collect/source/main/avida.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/main/avida.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -26,6 +26,7 @@
 
 #include "defs.h"
 #include "cActionLibrary.h"
+#include "cAnalyzeGenotype.h"
 #include "cAvidaConfig.h"
 #include "cDriverManager.h"
 #include "cString.h"
@@ -41,9 +42,19 @@
 #include <csignal>
 #include <cstdio>
 
+
 using namespace std;
 
+
 namespace Avida {
+  
+void Initialize()
+{
+  cActionLibrary::Initialize();
+  cAnalyzeGenotype::Initialize();
+}
+  
+  
 
 cString GetVersion()
 {
@@ -152,7 +163,7 @@
     // Print out a list of all possibel actions (was events).
     if (cur_arg == "-e" || cur_arg == "-events" || cur_arg == "-actions") {
       cout << endl << "Supported Actions:" << endl;
-      cout << cDriverManager::GetActionLibrary()->DescribeAll() << endl;
+      cout << cActionLibrary::GetInstance().DescribeAll() << endl;
       exit(0);
     }
     

Modified: branches/collect/source/main/avida.h
===================================================================
--- branches/collect/source/main/avida.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/main/avida.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -32,6 +32,8 @@
 
 namespace Avida
 {
+  void Initialize();
+  
   cString GetVersion();
   void PrintVersionBanner();
   

Modified: branches/collect/source/main/cEventList.cc
===================================================================
--- branches/collect/source/main/cEventList.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/main/cEventList.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -58,7 +58,7 @@
 bool cEventList::AddEvent(eTriggerType trigger, double start, double interval,
                           double stop, const cString& name, const cString& args)
 {
-  cAction* action = m_world->GetActionLibrary().Create(name, m_world, args);
+  cAction* action = cActionLibrary::GetInstance().Create(name, m_world, args);
   
   if (action != NULL) {
     cEventListEntry* entry = new cEventListEntry(action, name, trigger, start, interval, stop);

Modified: branches/collect/source/main/cWorld.cc
===================================================================
--- branches/collect/source/main/cWorld.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/main/cWorld.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -59,8 +59,6 @@
   if (m_data_mgr) { m_data_mgr->FlushAll(); }
   delete m_data_mgr; m_data_mgr = NULL;
   
-  cAnalyzeGenotype::DestroyDEDict(m_dedict_genotype);
-
   // Delete Last
   delete m_conf; m_conf = NULL;
 
@@ -81,8 +79,6 @@
   if (rand_seed != m_rng.GetSeed()) cout << " -> " << m_rng.GetSeed();
   cout << endl;
   
-  m_actlib = cDriverManager::GetActionLibrary();
-  
   m_data_mgr = new cDataFileManager(m_conf->DATA_DIR.Get(), (m_conf->VERBOSITY.Get() > VERBOSE_ON));
   if (m_conf->VERBOSITY.Get() > VERBOSE_NORMAL)
     cout << "Data Directory: " << m_data_mgr->GetTargetDir() << endl;
@@ -132,9 +128,6 @@
   const bool sterilize_neut = m_conf->STERILIZE_NEUTRAL.Get() > 0.0;
   const bool sterilize_pos = m_conf->STERILIZE_BENEFICIAL.Get() > 0.0;
   m_test_sterilize = (sterilize_fatal || sterilize_neg || sterilize_neut || sterilize_pos);
-
-  
-  m_dedict_genotype = cAnalyzeGenotype::BuildDEDict(this);
 }
 
 cAnalyze& cWorld::GetAnalyze()

Modified: branches/collect/source/main/cWorld.h
===================================================================
--- branches/collect/source/main/cWorld.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/main/cWorld.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -47,7 +47,6 @@
 
 #include <cassert>
 
-class cActionLibrary;
 class cAnalyze;
 class cAnalyzeGenotype;
 class cAvidaDriver;
@@ -68,7 +67,6 @@
   tMemTrack<cWorld> mt;
 #endif
 protected:
-  cActionLibrary* m_actlib;
   cAnalyze* m_analyze;
   cAvidaConfig* m_conf;
   cAvidaContext m_ctx;
@@ -80,7 +78,6 @@
   cPopulation* m_pop;
   cStats* m_stats;
   cWorldDriver* m_driver;
-  tDictionary<tDataEntry<cAnalyzeGenotype>*>* m_dedict_genotype;
 
   cRandom m_rng;
   
@@ -103,7 +100,6 @@
   void SetDriver(cWorldDriver* driver, bool take_ownership = false);
   
   // General Object Accessors
-  cActionLibrary& GetActionLibrary() { return *m_actlib; }
   cAnalyze& GetAnalyze();
   cAvidaConfig& GetConfig() { return *m_conf; }
   cAvidaContext& GetDefaultContext() { return m_ctx; }
@@ -116,8 +112,6 @@
   cStats& GetStats() { return *m_stats; }
   cWorldDriver& GetDriver() { return *m_driver; }
   
-  const tDictionary<tDataEntry<cAnalyzeGenotype>*>& GetGenotypeDEDict() const { return *m_dedict_genotype; }
-  
   // Access to Data File Manager
   std::ofstream& GetDataFileOFStream(const cString& fname) { return m_data_mgr->GetOFStream(fname); }
   cDataFile& GetDataFile(const cString& fname) { return m_data_mgr->Get(fname); }  
@@ -139,7 +133,6 @@
   // Save to archive 
   template<class Archive>
   void save(Archive & a, const unsigned int version) const {
-    a.ArkvObj("m_actlib", m_actlib);
     a.ArkvObj("m_analyze", m_analyze);
     a.ArkvObj("m_conf", m_conf);
     a.ArkvObj("m_ctx", m_ctx);
@@ -163,7 +156,6 @@
   // Load from archive 
   template<class Archive>
   void load(Archive & a, const unsigned int version){
-    a.ArkvObj("m_actlib", m_actlib);
     a.ArkvObj("m_analyze", m_analyze);
     a.ArkvObj("m_conf", m_conf);
     a.ArkvObj("m_ctx", m_ctx);

Modified: branches/collect/source/platform/PlatformExpert.cc
===================================================================
--- branches/collect/source/platform/PlatformExpert.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/platform/PlatformExpert.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -50,6 +50,7 @@
     signal(SIGINT, Avida::Exit);
 
     cDriverManager::Initialize();
+    Avida::Initialize();
   }
 
   

Modified: branches/collect/source/script/ASAnalyzeLib.cc
===================================================================
--- branches/collect/source/script/ASAnalyzeLib.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/script/ASAnalyzeLib.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -39,9 +39,10 @@
 #include "cGenotypeBatch.h"
 #include "cHardwareManager.h"
 #include "cInitFile.h"
+#include "cResourceHistory.h"
 #include "cWorld.h"
 
-#include "tDataEntryCommand.h"
+#include "tDataCommandManager.h"
 
 
 class cWorld;
@@ -116,7 +117,7 @@
     // Construct a linked list of data types that can be loaded...
     tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
     tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-    cAnalyzeGenotype::LoadDataCommandList(world, input_file.GetFormat(), output_list);
+    cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(input_file.GetFormat(), output_list);
     bool id_inc = input_file.GetFormat().HasString("id");
     
     // Setup the genome...
@@ -154,6 +155,17 @@
   }
   
   
+  cResourceHistory* LoadResourceHistory(const cString& filename)
+  {
+    cDriverStatusConduit& conduit = cDriverManager::Status();
+    conduit.NotifyComment(cString("Loading: ") + filename);
+
+    cResourceHistory* resources = new cResourceHistory;
+    if (!resources->LoadFile(filename)) conduit.SignalError("failed to load resource file", 1);
+    
+    return resources;
+  }
+  
 };
 
 
@@ -168,9 +180,10 @@
   BIND_FUNCTION(cWorld, "LoadOrganismWithInstSet", LoadOrganismWithInstSet, cAnalyzeGenotype* (const cString&, cInstSet*));
   BIND_FUNCTION(cWorld, "LoadSequence", LoadSequence, cAnalyzeGenotype* (const cString&));
   BIND_FUNCTION(cWorld, "LoadSequenceWithInstSet", LoadSequenceWithInstSet, cAnalyzeGenotype* (const cString&, cInstSet*));
-  BIND_FUNCTION(cWorld, "LoadBatch", LoadBatch, cAnalyzeGenotype* (const cString&));
-  BIND_FUNCTION(cWorld, "LoadBatchWithInstSet", LoadBatchWithInstSet, cAnalyzeGenotype* (const cString&, cInstSet*));
+  BIND_FUNCTION(cWorld, "LoadBatch", LoadBatch, cGenotypeBatch* (const cString&));
+  BIND_FUNCTION(cWorld, "LoadBatchWithInstSet", LoadBatchWithInstSet, cGenotypeBatch* (const cString&, cInstSet*));
 
+  REGISTER_FUNCTION(LoadResourceHistory, cResourceHistory* (const cString&));
 
 #undef BIND_FUNCTION
 #undef REGISTER_FUNCTION

Modified: branches/collect/source/script/ASAvidaLib.cc
===================================================================
--- branches/collect/source/script/ASAvidaLib.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/script/ASAvidaLib.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -61,6 +61,8 @@
   REGISTER_S_METHOD(cGenotypeBatch, "IsAligned", IsAligned, bool ());
   REGISTER_S_METHOD(cGenotypeBatch, "IsLineage", IsLineage, bool ());
 
+  tASNativeObject<cResourceHistory>::InitializeMethodRegistrar();
+
   tASNativeObject<cWorld>::InitializeMethodRegistrar();
   
   

Modified: branches/collect/source/script/ASAvidaNativeObjects.h
===================================================================
--- branches/collect/source/script/ASAvidaNativeObjects.h	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/script/ASAvidaNativeObjects.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -31,11 +31,12 @@
   class CLASS; \
   namespace AvidaScript { template<> inline sASTypeInfo TypeOf<CLASS*>() { return sASTypeInfo(AS_TYPE_OBJECT_REF, NAME); } }
 
-AS_DECLARE_NATIVE_OBJECT("Config",        cAvidaConfig);
-AS_DECLARE_NATIVE_OBJECT("Driver",        cDefaultRunDriver);
-AS_DECLARE_NATIVE_OBJECT("Genotype",      cAnalyzeGenotype);
-AS_DECLARE_NATIVE_OBJECT("GenotypeBatch", cGenotypeBatch);
-AS_DECLARE_NATIVE_OBJECT("World",         cWorld);
+AS_DECLARE_NATIVE_OBJECT("Config",          cAvidaConfig);
+AS_DECLARE_NATIVE_OBJECT("Driver",          cDefaultRunDriver);
+AS_DECLARE_NATIVE_OBJECT("Genotype",        cAnalyzeGenotype);
+AS_DECLARE_NATIVE_OBJECT("GenotypeBatch",   cGenotypeBatch);
+AS_DECLARE_NATIVE_OBJECT("ResourceHistory", cResourceHistory);
+AS_DECLARE_NATIVE_OBJECT("World",           cWorld);
 
 #undef AS_DECLARE_NATIVE_OBJECT
 

Modified: branches/collect/source/targets/avida-viewer/cTextViewerAnalyzeDriver.cc
===================================================================
--- branches/collect/source/targets/avida-viewer/cTextViewerAnalyzeDriver.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/targets/avida-viewer/cTextViewerAnalyzeDriver.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -48,13 +48,13 @@
 {
   m_view = new cAnalyzeView(world);
 
-  cDriverManager::Register(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Register(this);
   world->SetDriver(this);
 }
 
 cTextViewerAnalyzeDriver::~cTextViewerAnalyzeDriver()
 {
-  cDriverManager::Unregister(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Unregister(this);
 
   if (m_view != NULL) EndProg(0);
 }

Modified: branches/collect/source/targets/avida-viewer/cTextViewerDriver.cc
===================================================================
--- branches/collect/source/targets/avida-viewer/cTextViewerDriver.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/targets/avida-viewer/cTextViewerDriver.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -48,13 +48,13 @@
   m_view = new cView(world);
   m_view->SetViewMode(world->GetConfig().VIEW_MODE.Get());
 
-  cDriverManager::Register(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Register(this);
   world->SetDriver(this);
 }
 
 cTextViewerDriver::~cTextViewerDriver()
 {
-  cDriverManager::Unregister(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Unregister(this);
   
   if (m_view != NULL) EndProg(0);
 }

Modified: branches/collect/source/targets/viewer-text/cDriver_TextViewer.cc
===================================================================
--- branches/collect/source/targets/viewer-text/cDriver_TextViewer.cc	2008-11-01 22:49:12 UTC (rev 2910)
+++ branches/collect/source/targets/viewer-text/cDriver_TextViewer.cc	2008-11-01 23:23:53 UTC (rev 2911)
@@ -57,7 +57,7 @@
   // Setup the initial view mode (loaded from avida.cfg)
   m_info.SetViewMode(world->GetConfig().VIEW_MODE.Get());
     
-  cDriverManager::Register(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Register(this);
   world->SetDriver(this);
 
   // Setup NCURSES...
@@ -98,7 +98,7 @@
 
 cDriver_TextViewer::~cDriver_TextViewer()
 {
-  cDriverManager::Unregister(static_cast<cAvidaDriver*>(this));
+  cDriverManager::Unregister(this);
   delete m_world;
     
   ExitTextViewer(0);

Copied: branches/collect/source/tools/tDataCommandManager.h (from rev 2909, development/source/tools/tDataCommandManager.h)
===================================================================
--- branches/collect/source/tools/tDataCommandManager.h	                        (rev 0)
+++ branches/collect/source/tools/tDataCommandManager.h	2008-11-01 23:23:53 UTC (rev 2911)
@@ -0,0 +1,94 @@
+/*
+ *  tDataCommandManager.h
+ *  Avida
+ *
+ *  Created by David on 10/31/08.
+ *  Copyright 2008 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef tDataCommandManager_h
+#define tDataCommandManager_h
+
+#include "cStringUtil.h"
+#include "tDataEntry.h"
+#include "tDataEntryCommand.h"
+#include "tDictionary.h"
+#include "tList.h"
+
+
+template <class TargetType> class tDataCommandManager
+{
+private:
+  tDictionary<tDataEntry<TargetType>*> m_entry_dict;  
+  
+public:
+  tDataCommandManager() { ; }
+  ~tDataCommandManager()
+  {
+    tArray<tDataEntry<cAnalyzeGenotype>*> entries;
+    m_entry_dict.GetValues(entries);
+    for (int i = 0; i < entries.GetSize(); i++) delete entries[i];
+  }
+  
+  void Add(const cString& name, tDataEntry<TargetType>* entry) { m_entry_dict.Add(name, entry); }
+  
+
+  tDataEntryCommand<cAnalyzeGenotype>* GetDataCommand(const cString& cmd, cString** error_str = NULL) const
+  {
+    cString arg_list = cmd;
+    cString idx = arg_list.Pop(':');
+    cString entry_name = idx.Pop('.');
+    
+    tDataEntry<cAnalyzeGenotype>* data_entry;
+    if (m_entry_dict.Find(entry_name, data_entry)) {
+      return new tDataEntryCommand<cAnalyzeGenotype>(data_entry, idx, arg_list);
+    }
+    
+    if (error_str) {
+      (*error_str) = new cString(cStringUtil::Stringf("data entry '%s' not found, best match is '%s'", *entry_name,
+                                                      *(m_entry_dict.NearMatch(entry_name))));
+    }
+    
+    return NULL;
+  }
+  
+  void LoadCommandList(cStringList arg_list, tList<tDataEntryCommand<TargetType> >& output_list,
+                       tList<cString>* errors = NULL) const
+  {
+    if (arg_list.GetSize() == 0) {
+      // If no args were given, load all of the stats.
+      // @TODO - handle indexed items...  under this scheme only the first task and env_input value will be output    
+      
+      tArray<tDataEntry<TargetType>*> data_entries;
+      m_entry_dict.GetValues(data_entries);
+      for (int i = 0; i < data_entries.GetSize(); i++)
+        output_list.PushRear(new tDataEntryCommand<TargetType>(data_entries[i]));
+    } else {
+      while (arg_list.GetSize() != 0) {
+        cString* error_str = NULL;
+        tDataEntryCommand<TargetType>* cur_command = GetDataCommand(arg_list.Pop());
+        if (cur_command) output_list.PushRear(cur_command);
+        if (errors && error_str) errors->PushRear(error_str);
+      }
+    }
+  }
+};
+
+
+#endif




More information about the Avida-cvs mailing list