[Avida-cvs] [Avida2-svn] r383 - in development/source: cpu main support tools viewer

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Nov 9 13:56:36 PST 2005


Author: brysonda
Date: 2005-11-09 16:56:36 -0500 (Wed, 09 Nov 2005)
New Revision: 383

Modified:
   development/source/cpu/cHardwareManager.cc
   development/source/cpu/cHardwareManager.h
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/cpu/cHardwareSMT_Thread.cc
   development/source/cpu/cHardwareSMT_Thread.h
   development/source/cpu/cHardwareTracer_SMT.h
   development/source/cpu/nHardware.h
   development/source/cpu/nHardwareSMT.h
   development/source/cpu/tInstLib.h
   development/source/main/cAvidaConfig.cc
   development/source/main/cAvidaConfig.h
   development/source/main/cStats.h
   development/source/main/cWorld.cc
   development/source/main/cWorld.h
   development/source/main/nGenotype.h
   development/source/main/nGeometry.h
   development/source/main/nInjectGenotype.h
   development/source/main/nMutation.h
   development/source/main/nReaction.h
   development/source/main/nSpecies.h
   development/source/main/primitive.cc
   development/source/support/avida.cfg
   development/source/support/genesis.smt
   development/source/tools/cDataFileManager.cc
   development/source/tools/cDataFileManager.h
   development/source/tools/tDictionary.h
   development/source/tools/tObjectFactory.h
   development/source/viewer/viewer.cc
Log:
Rework cDataFileManager to use a dictionary mapping filenames to cDataFile objects.  Added support for setting the output directory used by a cDataFileManager on instantiation.  Updated cWorld to construct a cDataFileManager, though it is not used by anything yet.

Modified: development/source/cpu/cHardwareManager.cc
===================================================================
--- development/source/cpu/cHardwareManager.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareManager.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareManager.cc
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/18/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareManager.h
===================================================================
--- development/source/cpu/cHardwareManager.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareManager.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareManager.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/18/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareSMT.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareSMT.cc
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareSMT.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareSMT.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareSMT_Thread.cc
===================================================================
--- development/source/cpu/cHardwareSMT_Thread.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareSMT_Thread.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareSMT_Thread.cc
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareSMT_Thread.h
===================================================================
--- development/source/cpu/cHardwareSMT_Thread.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareSMT_Thread.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareSMT_Thread.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/cHardwareTracer_SMT.h
===================================================================
--- development/source/cpu/cHardwareTracer_SMT.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/cHardwareTracer_SMT.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cHardwareSMT.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 9/22/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/nHardware.h
===================================================================
--- development/source/cpu/nHardware.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/nHardware.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nHardware.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 8/29/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/nHardwareSMT.h
===================================================================
--- development/source/cpu/nHardwareSMT.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/nHardwareSMT.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nHardwareSMT.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/cpu/tInstLib.h
===================================================================
--- development/source/cpu/tInstLib.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/cpu/tInstLib.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  tInstLib.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/4/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/cAvidaConfig.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cAvidaConfig.cc
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/16/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/cAvidaConfig.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cAvidaConfig.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/16/05.
  *  Designed by Charles.
@@ -167,7 +167,7 @@
   CONFIG_ADD_VAR(HARDWARE_TYPE, int, 0, "0 = Original CPUs\n1 = New, Stack-based CPUs\n2 = Newer -- Stacks, Memory, Threading");
   
   CONFIG_ADD_GROUP(CONFIG_FILE_GROUP, "Configuration Files");
-  CONFIG_ADD_VAR(DEFAULT_DIR, cString, "../work/", "Directory in which config files are found");
+  CONFIG_ADD_VAR(DATA_DIR, cString, ".", "Directory in which config files are found");
   CONFIG_ADD_VAR(INST_SET, cString, "inst_set.default", "File containing instruction set");
   CONFIG_ADD_VAR(EVENT_FILE, cString, "events.cfg", "File containing list of events during run");
   CONFIG_ADD_VAR(ANALYZE_FILE, cString, "analyze.cfg", "File used for analysis mode");

Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/cStats.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -15,7 +15,7 @@
 #ifndef DEFS_HH
 #include "defs.h"
 #endif
-#ifndef DATA_FILE_MANAGER_HH
+#ifndef cDataFileManager_h
 #include "cDataFileManager.h"
 #endif
 #ifndef DOUBLE_SUM_HH
@@ -39,7 +39,6 @@
 #include "nGeometry.h"
 
 template <class T> class tDataManager; // aggregate
-class cDataFileManager; // aggregate
 class cDoubleSum; // aggregate
 class cRunningAverage; // aggregate
 class cIntSum; // aggregate

Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/cWorld.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cWorld.cc
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/18/05.
  *  Copyright 2005 Michigan State University. All rights reserved.
@@ -21,13 +21,21 @@
 #include "cTools.h"
 
 cWorld::~cWorld()
-{ 
+{
+  m_data_mgr->FlushAll();
+
   delete m_conf;
+  delete m_data_mgr;
+  delete m_env;
+  delete m_event_mgr;
+  delete m_event_list;
+  delete m_hw_mgr;
   delete m_pop;
-  delete m_hw_mgr;
+  delete m_test_cpu;
 }
 
-void cWorld::Setup() {
+void cWorld::Setup()
+{
   // Setup Random Number Generator
   const int rand_seed = m_conf->RANDOM_SEED.Get();
   cout << "Random Seed: " << rand_seed;
@@ -35,13 +43,14 @@
   if (rand_seed != m_rng.GetSeed()) cout << " -> " << m_rng.GetSeed();
   cout << endl;
   
-  // The default directory should end in a '/'.
-  cString default_dir = m_conf->DEFAULT_DIR.Get();
-  char dir_tail = default_dir[default_dir.GetSize() - 1];
+  // The data directory should end in a '/'
+  cString dir = m_conf->DATA_DIR.Get();
+  char dir_tail = dir[dir.GetSize() - 1];
   if (dir_tail != '\\' && dir_tail != '/') {
-    default_dir += "/";
-    m_conf->DEFAULT_DIR.Set(default_dir);
+    dir += "/";
+    m_conf->DATA_DIR.Set(dir);
   }
+  m_data_mgr = new cDataFileManager(dir);
   
   m_env = new cEnvironment(this);
   m_hw_mgr = new cHardwareManager(this);

Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/cWorld.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  cWorld.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/18/05.
  *  Copyright 2005 Michigan State University. All rights reserved.
@@ -13,6 +13,9 @@
 #ifndef cAvidaConfig_h
 #include "cAvidaConfig.h"
 #endif
+#ifndef cDataFileManager_h
+#include "cDataFileManager.h"
+#endif
 #ifndef cRandom_h
 #include "cRandom.h"
 #endif
@@ -28,9 +31,10 @@
 {
 protected:
   cAvidaConfig* m_conf;
+  cDataFileManager* m_data_mgr;
+  cEnvironment* m_env;
   cEventManager* m_event_mgr;
   cEventList* m_event_list;
-  cEnvironment* m_env;
   cHardwareManager* m_hw_mgr;
   cPopulation* m_pop;
   cTestCPU* m_test_cpu;
@@ -49,12 +53,17 @@
   
   void SetConfig(cAvidaConfig* cfg) { delete m_conf; m_conf = cfg; }
   
+  // General Object Accessors
   cAvidaConfig& GetConfig() { return *m_conf; }
   cEnvironment& GetEnvironment() { return *m_env; }
   cHardwareManager& GetHardwareManager() { return *m_hw_mgr; }
   cPopulation& GetPopulation() { return *m_pop; }
   cRandom& GetRandom() { return m_rng; }
   cTestCPU& GetTestCPU() { return *m_test_cpu; }
+  
+  // 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); }  
 
   // Config Dependent Modes
   bool GetTestOnDivide() const { return m_test_on_div; }

Modified: development/source/main/nGenotype.h
===================================================================
--- development/source/main/nGenotype.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nGenotype.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nGenotype.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/5/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/nGeometry.h
===================================================================
--- development/source/main/nGeometry.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nGeometry.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nGeometry.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/6/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/nInjectGenotype.h
===================================================================
--- development/source/main/nInjectGenotype.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nInjectGenotype.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nInjectGenotype.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/5/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/nMutation.h
===================================================================
--- development/source/main/nMutation.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nMutation.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nGeometry.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/5/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/nReaction.h
===================================================================
--- development/source/main/nReaction.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nReaction.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nReaction.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/6/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/nSpecies.h
===================================================================
--- development/source/main/nSpecies.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/nSpecies.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  nSpecies.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/5/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/main/primitive.cc
===================================================================
--- development/source/main/primitive.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/main/primitive.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  primitive.cc
- *  Avida2
+ *  Avida
  *
  *  Copyright 2005 Michigan State University. All rights reserved.
  *

Modified: development/source/support/avida.cfg
===================================================================
--- development/source/support/avida.cfg	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/support/avida.cfg	2005-11-09 21:56:36 UTC (rev 383)
@@ -33,7 +33,7 @@
 
 ### CONFIG_FILE_GROUP ###
 # Configuration Files
-DEFAULT_DIR ../work/              # Directory in which config files are found
+DATA_DIR .                        # Directory in which config files are found
 INST_SET inst_set.smt             # File containing instruction set
 EVENT_FILE events.cfg             # File containing list of events during run
 ANALYZE_FILE analyze.cfg          # File used for analysis mode

Modified: development/source/support/genesis.smt
===================================================================
--- development/source/support/genesis.smt	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/support/genesis.smt	2005-11-09 21:56:36 UTC (rev 383)
@@ -20,7 +20,7 @@
 MAX_CPU_THREADS 1       # Number of Threads CPUs can spawn
 
 ### Configuration Files ###
-DEFAULT_DIR ../Avida2.work/              # Directory in which config files are found
+DEFAULT_DIR ../Avida.work/              # Directory in which config files are found
 INST_SET inst_set.smt             # File containing instruction set
 EVENT_FILE events.cfg             # File containing list of events during run
 ANALYZE_FILE analyze.cfg          # File used for analysis mode

Modified: development/source/tools/cDataFileManager.cc
===================================================================
--- development/source/tools/cDataFileManager.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/tools/cDataFileManager.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,97 +1,53 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cDataFileManager.cc
+ *  Avida
+ *
+ *  Created by David on 10/18/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1993-2005 California Institute of Technology
+ *
+ */
 
-#ifndef DATA_FILE_MANAGER_HH
 #include "cDataFileManager.h"
-#endif
 
-#ifndef DATA_FILE_HH
-#include "cDataFile.h"
-#endif
-
 using namespace std;
 
-//////////////////////
-//  cDataFileManager
-//////////////////////
-
-
 cDataFileManager::~cDataFileManager()
 {
-  while (data_file_list.GetSize()) {
-    delete data_file_list.Pop();
-  }
+  tList<cString> names;
+  tList<cDataFile*> files;
+  m_datafiles.AsLists(names, files);
+  tListIterator<cDataFile*> list_it(files);
+  while (list_it.Next() != NULL) delete *list_it.Get();
 }
 
-
-cDataFile * cDataFileManager::InternalFind(const cString & name)
-{
-  tListIterator<cDataFile> list_it(data_file_list);
-  while (list_it.Next() != NULL) {
-    if (list_it.Get()->GetName() == name) return list_it.Get();
-  }
-  return NULL;
-}
-
-
 cDataFile & cDataFileManager::Get(const cString & name)
 {
   // Find the file by this name...
-  cDataFile * found_file = InternalFind(name);
+  cDataFile* found_file;
 
   // If it hasn't been found, create it...
-  if (found_file == NULL) {
-    found_file = new cDataFile(name);
-    data_file_list.Push(found_file);
+  if (m_datafiles.Find(name, found_file)) {
+    found_file = new cDataFile(m_target_dir + name);
+    m_datafiles.Add(name, found_file);
   }
 
-  // Make sure we got the name right...
-  assert( found_file->GetName() == name );
-
   // and return it.
   return *found_file;
 }
 
-
-ofstream & cDataFileManager::GetOFStream(const cString & name)
-{
-  // Find the file by this name...
-  cDataFile * found_file = InternalFind(name);
-
-  // If it hasn't been found, create it...
-  if (found_file == NULL) {
-    found_file = new cDataFile(name);
-    data_file_list.Push(found_file);
-  }
-
-  // Make sure we got the name right...
-  assert( found_file->GetName() == name );
-
-  // And return the releven stream...
-  return found_file->GetOFStream();
-}
-
-bool cDataFileManager::IsOpen(const cString & name)
-{
-  if (InternalFind(name) == NULL) return false;
-  return true;
-}
-
-
 void cDataFileManager::FlushAll()
 {
-  tListIterator<cDataFile> list_it(data_file_list);
-  while (list_it.Next() != NULL) list_it.Get()->Flush();
+  tList<cString> names;
+  tList<cDataFile*> files;
+  m_datafiles.AsLists(names, files);
+  tListIterator<cDataFile*> list_it(files);
+  while (list_it.Next() != NULL) (*list_it.Get())->Flush();
 }
 
-
-bool cDataFileManager::Remove(const cString & name)
+bool cDataFileManager::Remove(const cString& name)
 {
-  cDataFile * found_file = InternalFind(name);
+  cDataFile* found_file = m_datafiles.Remove(name);
   if (found_file == NULL) return false;
 
   delete found_file;

Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/tools/cDataFileManager.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,27 +1,24 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cDataFileManager.h
+ *  Avida
+ *
+ *  Created by David on 10/18/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1993-2005 California Institute of Technology
+ *
+ */
 
-/* cDataFileManager.h ********************************************************
- cDataFileManager
+#ifndef cDataFileManager_h
+#define cDataFileManager_h
 
- charles at krl.caltech.edu & travc at ugcs.caltech.edu
- Time-stamp: <1999-01-07 10:02:09 travc>
-
- cString: basic string class
-******************************************************************************/
-
-#ifndef DATA_FILE_MANAGER_HH
-#define DATA_FILE_MANAGER_HH
-
 #include <fstream>
 
-#ifndef TLIST_HH
-#include "tList.h"
+#ifndef cDataFile_h
+#include "cDataFile.h"
 #endif
+#ifndef tDictionary_h
+#include "tDictionary.h"
+#endif
 
 /**
  * This class helps to manage a collection of data files. It is possible
@@ -34,15 +31,16 @@
 
 class cDataFileManager {
 private:
-  tList<cDataFile> data_file_list;
+  cString m_target_dir;
+  tDictionary<cDataFile*> m_datafiles;
 
-  cDataFile * InternalFind(const cString & name);
+  cDataFile* InternalFind(const cString & name);
 
-private:
   // disabled copy constructor.
   cDataFileManager(const cDataFileManager &);
+  
 public:
-  cDataFileManager() { ; }
+  inline cDataFileManager(cString target_dir = "");
   ~cDataFileManager();
 
   /**
@@ -52,29 +50,34 @@
    * @return The @ref cDataFile.
    * @param name The name of the file to look up/create.
    **/
-  cDataFile & Get(const cString & name);
+  cDataFile& Get(const cString & name);
+  std::ofstream& GetOFStream(const cString& name) { return Get(name).GetOFStream(); }
 
-  /**
-   * Looks up the ofstream corresponding to the file of the given name.
-   * If that file hasn't been created previously, it is created now.
-   *
-   * Read the cautionary remarks about the function with the same name in
-   * @ref cDataFile.
-   *
-   * @return The ofstream.
-   * @param name The name of the file to look up/create.
-   **/
-  std::ofstream & GetOFStream(const cString & name);
+  inline bool IsOpen(const cString& name);
 
-  bool IsOpen(const cString & name);
-
   void FlushAll();
 
   /** Removes the given file, thereby closing it.
    *
    * @return true if file existed, otherwise false.
    **/
-  bool Remove(const cString & name);
+  bool Remove(const cString& name);
 };
 
+inline cDataFileManager::cDataFileManager(cString target_dir) : m_target_dir(target_dir)
+{
+  if (m_target_dir.GetSize() > 0) {
+    char dir_tail = m_target_dir[m_target_dir.GetSize() - 1];
+    if (dir_tail != '\\' && dir_tail != '/') m_target_dir += "/";
+  }
+}
+
+inline bool cDataFileManager::IsOpen(const cString & name)
+{
+  cDataFile* found;
+  if (m_datafiles.Find(name, found)) return false;
+  return true;
+}
+
+
 #endif

Modified: development/source/tools/tDictionary.h
===================================================================
--- development/source/tools/tDictionary.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/tools/tDictionary.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  tDictionary.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 10/11/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/tools/tObjectFactory.h
===================================================================
--- development/source/tools/tObjectFactory.h	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/tools/tObjectFactory.h	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  tObjectFactory.h
- *  Avida2
+ *  Avida
  *
  *  Created by David on 6/10/05.
  *  Copyright 2005 Michigan State University. All rights reserved.

Modified: development/source/viewer/viewer.cc
===================================================================
--- development/source/viewer/viewer.cc	2005-11-08 21:09:13 UTC (rev 382)
+++ development/source/viewer/viewer.cc	2005-11-09 21:56:36 UTC (rev 383)
@@ -1,6 +1,6 @@
 /*
  *  viewer.cc
- *  Avida2
+ *  Avida
  *
  *  Copyright 2005 Michigan State University. All rights reserved.
  *




More information about the Avida-cvs mailing list