[Avida-SVN] r3468 - in development/source: main tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Oct 13 12:24:33 PDT 2009


Author: brysonda
Date: 2009-10-13 15:24:33 -0400 (Tue, 13 Oct 2009)
New Revision: 3468

Modified:
   development/source/main/avida.cc
   development/source/main/cAvidaConfig.cc
   development/source/main/cAvidaConfig.h
   development/source/tools/cInitFile.cc
   development/source/tools/cInitFile.h
Log:
Add command line option to toggle configuration 'defaulting to' warnings.  These are now disabled by default.  Pass -w or -warn to enable the warnings.

Modified: development/source/main/avida.cc
===================================================================
--- development/source/main/avida.cc	2009-10-13 11:56:36 UTC (rev 3467)
+++ development/source/main/avida.cc	2009-10-13 19:24:33 UTC (rev 3468)
@@ -155,6 +155,7 @@
   bool flag_review = false;
   bool flag_verbosity = false;    int val_verbosity = 0;
   bool flag_seed = false;         int val_seed = 0;
+  bool flag_warn_default = false;
   
   // Then scan through and process the rest of the args.
   while (arg_num < argc) {
@@ -189,6 +190,7 @@
       << "  -set <name> <value>   Override values in avida.cfg" << endl
       << "  -v[ersion]            Prints the version number" << endl
       << "  -v0 -v1 -v2 -v3 -v4   Set output verbosity to 0..4" << endl
+      << "  -w[arn]               Warn when default config settings are used." << endl
       << endl;
       
       exit(0);
@@ -206,6 +208,8 @@
       flag_analyze = true;
     } else if (cur_arg == "-interactive" || cur_arg == "-i") {
       flag_interactive = true;
+    } else if (cur_arg == "-warn" || cur_arg == "-w") {
+      flag_warn_default = true;
     } else if (cur_arg == "-load" || cur_arg == "-l") {
       if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
         cerr << "Error: Must include a filename to load from." << endl;
@@ -261,7 +265,7 @@
   delete [] args;
 
   // Load configuration file
-  cfg->Load(config_filename, defs, crash_if_not_found);
+  cfg->Load(config_filename, defs, crash_if_not_found, flag_warn_default);
   
 
   // Process Command Line Flags

Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc	2009-10-13 11:56:36 UTC (rev 3467)
+++ development/source/main/cAvidaConfig.cc	2009-10-13 19:24:33 UTC (rev 3468)
@@ -62,7 +62,7 @@
 }
 
 
-void cAvidaConfig::Load(const cString& filename, const tDictionary<cString>& mappings, bool crash_if_not_found)
+void cAvidaConfig::Load(const cString& filename, const tDictionary<cString>& mappings, bool crash_if_not_found, bool warn_default)
 {
   // Load the contents from the file.
   cInitFile init_file(filename, mappings);
@@ -103,7 +103,7 @@
     while ((cur_entry = entry_it.Next()) != NULL) {
       const cString keyword = cur_entry->GetName();
       const cString default_val = cur_entry->GetDefault();
-      cur_entry->LoadString( init_file.ReadString(keyword, default_val) );
+      cur_entry->LoadString( init_file.ReadString(keyword, default_val, warn_default) );
     }
   }
   

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2009-10-13 11:56:36 UTC (rev 3467)
+++ development/source/main/cAvidaConfig.h	2009-10-13 19:24:33 UTC (rev 3468)
@@ -685,7 +685,7 @@
   
   inline void Load(const cString& filename) { Load(filename, false); }
   void Load(const cString& filename, bool crash_if_not_found);
-  void Load(const cString& filename, const tDictionary<cString>& mappings, bool crash_if_not_found = false);
+  void Load(const cString& filename, const tDictionary<cString>& mappings, bool crash_if_not_found = false, bool warn_default = true);
   void Print(const cString& filename);
   void Status();
   void PrintReview();

Modified: development/source/tools/cInitFile.cc
===================================================================
--- development/source/tools/cInitFile.cc	2009-10-13 11:56:36 UTC (rev 3467)
+++ development/source/tools/cInitFile.cc	2009-10-13 19:24:33 UTC (rev 3468)
@@ -249,7 +249,7 @@
 }
 
 
-cString cInitFile::ReadString(const cString& name, cString def) const
+cString cInitFile::ReadString(const cString& name, cString def, bool warn_default) const
 {
   // See if we definately can't find the keyword.
   if (name == "") return def;
@@ -257,8 +257,10 @@
   // Search for the keyword.
   cString cur_line;
   if (Find(cur_line, name, 0) == false) {
-    m_errors.PushRear(new cString(cStringUtil::Stringf("%s not in '%s', defaulting to: %s",
-                                                       (const char*)name, (const char*)m_filename, (const char*)def)));
+    if (warn_default) {
+      m_errors.PushRear(new cString(cStringUtil::Stringf("%s not in '%s', defaulting to: %s",
+                                                         (const char*)name, (const char*)m_filename, (const char*)def)));
+    }
     return def;
   }
 

Modified: development/source/tools/cInitFile.h
===================================================================
--- development/source/tools/cInitFile.h	2009-10-13 11:56:36 UTC (rev 3467)
+++ development/source/tools/cInitFile.h	2009-10-13 19:24:33 UTC (rev 3468)
@@ -133,7 +133,7 @@
    * one to set standard values that are used if the user does not override
    * them.
    **/
-  cString ReadString(const cString& name, cString def = "") const;
+  cString ReadString(const cString& name, cString def = "", bool warn_default = true) const;
   
   /**
    * Looks over all lines loaded into the file, and warns if any of them




More information about the Avida-cvs mailing list