[Avida-cvs] [avida-svn] r442 - in development: Avida.xcodeproj source/analyze source/classification source/cpu source/event source/main source/targets/avida-viewer source/tools
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Jan 20 05:46:48 PST 2006
Author: brysonda
Date: 2006-01-20 08:46:47 -0500 (Fri, 20 Jan 2006)
New Revision: 442
Removed:
development/source/tools/cCountTracker.cc
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyze.h
development/source/analyze/cAnalyzeGenotype.cc
development/source/analyze/cAnalyzeGenotype.h
development/source/analyze/cAnalyzeUtil.cc
development/source/classification/cClassificationManager.cc
development/source/classification/cLineage.cc
development/source/cpu/cHardwareStatusPrinter.cc
development/source/cpu/cTestUtil.cc
development/source/event/cEventManager.cc
development/source/main/cEnvironment.cc
development/source/main/cPopulation.cc
development/source/targets/avida-viewer/cEnvironmentScreen.cc
development/source/tools/CMakeLists.txt
development/source/tools/cChangeList.cc
development/source/tools/cChangeList.h
development/source/tools/cConstSchedule.cc
development/source/tools/cConstSchedule.h
development/source/tools/cCountTracker.h
development/source/tools/cDataFile.cc
development/source/tools/cDataFile.h
development/source/tools/cDataFileManager.cc
development/source/tools/cDataFileManager.h
development/source/tools/cDataManager_Base.h
development/source/tools/cDefaultMessageDisplay.cc
development/source/tools/cDefaultMessageDisplay.h
development/source/tools/cDoubleSum.h
development/source/tools/cFile.cc
development/source/tools/cFile.h
development/source/tools/cHelpEntry.h
development/source/tools/cHelpType.cc
development/source/tools/cInitFile.h
development/source/tools/cIntSum.h
development/source/tools/cIntegratedSchedule.h
development/source/tools/cIntegratedScheduleNode.cc
development/source/tools/cIntegratedScheduleNode.h
development/source/tools/cMerit.h
development/source/tools/cProbSchedule.h
development/source/tools/cRandom.h
development/source/tools/cRunningAverage.h
development/source/tools/cSchedule.h
development/source/tools/cString.cc
development/source/tools/cString.h
development/source/tools/cStringIterator.h
development/source/tools/cStringList.h
development/source/tools/cStringUtil.h
development/source/tools/cTools.cc
development/source/tools/cTools.h
development/source/tools/cUInt.h
development/source/tools/cWeightedIndex.h
Log:
Update coding style, specifically addressing unimplemented default constructor, copy constructor and assignment operator, for a number of classes in tools.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2006-01-18 19:32:53 UTC (rev 441)
+++ development/Avida.xcodeproj/project.pbxproj 2006-01-20 13:46:47 UTC (rev 442)
@@ -124,10 +124,8 @@
70B0874D08F5E82D00FC65FE /* cTaskLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0872D08F5E82D00FC65FE /* cTaskLib.cc */; };
70B087E208F5F4BA00FC65FE /* cChangeList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087DF08F5F4BA00FC65FE /* cChangeList.cc */; };
70B087E308F5F4BA00FC65FE /* cConstSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E008F5F4BA00FC65FE /* cConstSchedule.cc */; };
- 70B087E408F5F4BA00FC65FE /* cCountTracker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E108F5F4BA00FC65FE /* cCountTracker.cc */; };
70B087E508F5F4BA00FC65FE /* cChangeList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087DF08F5F4BA00FC65FE /* cChangeList.cc */; };
70B087E608F5F4BA00FC65FE /* cConstSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E008F5F4BA00FC65FE /* cConstSchedule.cc */; };
- 70B087E708F5F4BA00FC65FE /* cCountTracker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E108F5F4BA00FC65FE /* cCountTracker.cc */; };
70B0885508F5FE5800FC65FE /* cDataFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0884F08F5FE5800FC65FE /* cDataFile.cc */; };
70B0885608F5FE5800FC65FE /* cDataFileManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885008F5FE5800FC65FE /* cDataFileManager.cc */; };
70B0885708F5FE5800FC65FE /* cDataManager_Base.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885108F5FE5800FC65FE /* cDataManager_Base.cc */; };
@@ -139,9 +137,7 @@
70B0885E08F5FE5800FC65FE /* cDefaultMessageDisplay.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885208F5FE5800FC65FE /* cDefaultMessageDisplay.cc */; };
70B0885F08F5FE5800FC65FE /* cDoubleSum.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885308F5FE5800FC65FE /* cDoubleSum.cc */; };
70B0888508F603D400FC65FE /* cFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888308F603D400FC65FE /* cFile.cc */; };
- 70B0888608F603D400FC65FE /* cGenesis.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888408F603D400FC65FE /* cGenesis.cc */; };
70B0888708F603D400FC65FE /* cFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888308F603D400FC65FE /* cFile.cc */; };
- 70B0888808F603D400FC65FE /* cGenesis.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888408F603D400FC65FE /* cGenesis.cc */; };
70B0892708F7630100FC65FE /* cHelpAlias.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891608F7630100FC65FE /* cHelpAlias.cc */; };
70B0892808F7630100FC65FE /* cHelpManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891708F7630100FC65FE /* cHelpManager.cc */; };
70B0892908F7630100FC65FE /* cHelpType.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891808F7630100FC65FE /* cHelpType.cc */; };
@@ -301,14 +297,12 @@
70DCACD0097AF7CC002F8733 /* cTaskLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0872D08F5E82D00FC65FE /* cTaskLib.cc */; };
70DCACD1097AF7CC002F8733 /* cChangeList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087DF08F5F4BA00FC65FE /* cChangeList.cc */; };
70DCACD2097AF7CC002F8733 /* cConstSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E008F5F4BA00FC65FE /* cConstSchedule.cc */; };
- 70DCACD3097AF7CC002F8733 /* cCountTracker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B087E108F5F4BA00FC65FE /* cCountTracker.cc */; };
70DCACD4097AF7CC002F8733 /* cDataFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0884F08F5FE5800FC65FE /* cDataFile.cc */; };
70DCACD5097AF7CC002F8733 /* cDataFileManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885008F5FE5800FC65FE /* cDataFileManager.cc */; };
70DCACD6097AF7CC002F8733 /* cDataManager_Base.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885108F5FE5800FC65FE /* cDataManager_Base.cc */; };
70DCACD7097AF7CC002F8733 /* cDefaultMessageDisplay.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885208F5FE5800FC65FE /* cDefaultMessageDisplay.cc */; };
70DCACD8097AF7CC002F8733 /* cDoubleSum.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0885308F5FE5800FC65FE /* cDoubleSum.cc */; };
70DCACD9097AF7CC002F8733 /* cFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888308F603D400FC65FE /* cFile.cc */; };
- 70DCACDA097AF7CC002F8733 /* cGenesis.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0888408F603D400FC65FE /* cGenesis.cc */; };
70DCACDB097AF7CC002F8733 /* cHelpAlias.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891608F7630100FC65FE /* cHelpAlias.cc */; };
70DCACDC097AF7CC002F8733 /* cHelpManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891708F7630100FC65FE /* cHelpManager.cc */; };
70DCACDD097AF7CC002F8733 /* cHelpType.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891808F7630100FC65FE /* cHelpType.cc */; };
@@ -627,7 +621,6 @@
70B087DE08F5F4A900FC65FE /* cVerifierSuiteRecurser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cVerifierSuiteRecurser.h; sourceTree = "<group>"; };
70B087DF08F5F4BA00FC65FE /* cChangeList.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cChangeList.cc; sourceTree = "<group>"; };
70B087E008F5F4BA00FC65FE /* cConstSchedule.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cConstSchedule.cc; sourceTree = "<group>"; };
- 70B087E108F5F4BA00FC65FE /* cCountTracker.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCountTracker.cc; sourceTree = "<group>"; };
70B0884808F5FE4500FC65FE /* cDataEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDataEntry.h; sourceTree = "<group>"; };
70B0884908F5FE4500FC65FE /* cDataFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDataFile.h; sourceTree = "<group>"; };
70B0884A08F5FE4500FC65FE /* cDataFileManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDataFileManager.h; sourceTree = "<group>"; };
@@ -1525,7 +1518,6 @@
70B0884D08F5FE4500FC65FE /* cDoubleSum.h */,
70B087DF08F5F4BA00FC65FE /* cChangeList.cc */,
70B087E008F5F4BA00FC65FE /* cConstSchedule.cc */,
- 70B087E108F5F4BA00FC65FE /* cCountTracker.cc */,
70B087D708F5F4A900FC65FE /* cBlockStruct.cc */,
70B087D808F5F4A900FC65FE /* cBlockStruct.h */,
70B087D908F5F4A900FC65FE /* cChangeList.h */,
@@ -1846,14 +1838,12 @@
70B0874D08F5E82D00FC65FE /* cTaskLib.cc in Sources */,
70B087E508F5F4BA00FC65FE /* cChangeList.cc in Sources */,
70B087E608F5F4BA00FC65FE /* cConstSchedule.cc in Sources */,
- 70B087E708F5F4BA00FC65FE /* cCountTracker.cc in Sources */,
70B0885B08F5FE5800FC65FE /* cDataFile.cc in Sources */,
70B0885C08F5FE5800FC65FE /* cDataFileManager.cc in Sources */,
70B0885D08F5FE5800FC65FE /* cDataManager_Base.cc in Sources */,
70B0885E08F5FE5800FC65FE /* cDefaultMessageDisplay.cc in Sources */,
70B0885F08F5FE5800FC65FE /* cDoubleSum.cc in Sources */,
70B0888708F603D400FC65FE /* cFile.cc in Sources */,
- 70B0888808F603D400FC65FE /* cGenesis.cc in Sources */,
70B0893808F7630100FC65FE /* cHelpAlias.cc in Sources */,
70B0893908F7630100FC65FE /* cHelpManager.cc in Sources */,
70B0893A08F7630100FC65FE /* cHelpType.cc in Sources */,
@@ -1968,14 +1958,12 @@
70DCACD0097AF7CC002F8733 /* cTaskLib.cc in Sources */,
70DCACD1097AF7CC002F8733 /* cChangeList.cc in Sources */,
70DCACD2097AF7CC002F8733 /* cConstSchedule.cc in Sources */,
- 70DCACD3097AF7CC002F8733 /* cCountTracker.cc in Sources */,
70DCACD4097AF7CC002F8733 /* cDataFile.cc in Sources */,
70DCACD5097AF7CC002F8733 /* cDataFileManager.cc in Sources */,
70DCACD6097AF7CC002F8733 /* cDataManager_Base.cc in Sources */,
70DCACD7097AF7CC002F8733 /* cDefaultMessageDisplay.cc in Sources */,
70DCACD8097AF7CC002F8733 /* cDoubleSum.cc in Sources */,
70DCACD9097AF7CC002F8733 /* cFile.cc in Sources */,
- 70DCACDA097AF7CC002F8733 /* cGenesis.cc in Sources */,
70DCACDB097AF7CC002F8733 /* cHelpAlias.cc in Sources */,
70DCACDC097AF7CC002F8733 /* cHelpManager.cc in Sources */,
70DCACDD097AF7CC002F8733 /* cHelpType.cc in Sources */,
@@ -2083,14 +2071,12 @@
70B0873D08F5E82D00FC65FE /* cTaskLib.cc in Sources */,
70B087E208F5F4BA00FC65FE /* cChangeList.cc in Sources */,
70B087E308F5F4BA00FC65FE /* cConstSchedule.cc in Sources */,
- 70B087E408F5F4BA00FC65FE /* cCountTracker.cc in Sources */,
70B0885508F5FE5800FC65FE /* cDataFile.cc in Sources */,
70B0885608F5FE5800FC65FE /* cDataFileManager.cc in Sources */,
70B0885708F5FE5800FC65FE /* cDataManager_Base.cc in Sources */,
70B0885808F5FE5800FC65FE /* cDefaultMessageDisplay.cc in Sources */,
70B0885908F5FE5800FC65FE /* cDoubleSum.cc in Sources */,
70B0888508F603D400FC65FE /* cFile.cc in Sources */,
- 70B0888608F603D400FC65FE /* cGenesis.cc in Sources */,
70B0892708F7630100FC65FE /* cHelpAlias.cc in Sources */,
70B0892808F7630100FC65FE /* cHelpManager.cc in Sources */,
70B0892908F7630100FC65FE /* cHelpType.cc in Sources */,
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/analyze/cAnalyze.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -2460,7 +2460,7 @@
filename = "community.complexity.dat";
}
- filename.Set("%s%s", directory(), filename.GetData());
+ filename.Set("%s%s", static_cast<const char*>(directory), static_cast<const char*>(filename));
ofstream& cpx_fp = m_world->GetDataFileOFStream(filename);
cpx_fp << "# Legend:" << endl;
@@ -2949,7 +2949,7 @@
filename = "community.complexity.dat";
}
- filename.Set("%s%s", directory(), filename.GetData());
+ filename.Set("%s%s", static_cast<const char*>(directory), static_cast<const char*>(filename));
ofstream& cpx_fp = m_world->GetDataFileOFStream(filename);
cpx_fp << "# Legend:" << endl;
@@ -3899,9 +3899,9 @@
// Construct this filename...
cString filename;
if (file_type == FILE_TYPE_TEXT) {
- filename.Set("%stasksites.%s.dat", directory(), genotype->GetName()());
+ filename.Set("%stasksites.%s.dat", static_cast<const char*>(directory), static_cast<const char*>(genotype->GetName()));
} else { // if (file_type == FILE_TYPE_HTML) {
- filename.Set("%stasksites.%s.html", directory(), genotype->GetName()());
+ filename.Set("%stasksites.%s.html", static_cast<const char*>(directory), static_cast<const char*>(genotype->GetName()));
}
ofstream& fp = m_world->GetDataFileOFStream(filename);
@@ -3911,13 +3911,13 @@
if (link_maps == true) {
// Check the next genotype on the list...
if (batch_it.Next() != NULL) {
- next_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
+ next_file.Set("tasksites.%s.html", static_cast<const char*>(batch_it.Get()->GetName()));
}
batch_it.Prev(); // Put the list back where it was...
// Check the previous genotype on the list...
if (batch_it.Prev() != NULL) {
- prev_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
+ prev_file.Set("tasksites.%s.html", static_cast<const char*>(batch_it.Get()->GetName()));
}
batch_it.Next(); // Put the list back where it was...
}
@@ -4512,9 +4512,9 @@
// Construct this filename...
cString filename;
if (file_type == FILE_TYPE_TEXT) {
- filename.Set("%smut_map.%s.dat", directory(), genotype->GetName()());
+ filename.Set("%smut_map.%s.dat", static_cast<const char*>(directory), static_cast<const char*>(genotype->GetName()));
} else { // if (file_type == FILE_TYPE_HTML) {
- filename.Set("%smut_map.%s.html", directory(), genotype->GetName()());
+ filename.Set("%smut_map.%s.html", static_cast<const char*>(directory), static_cast<const char*>(genotype->GetName()));
}
ofstream& fp = m_world->GetDataFileOFStream(filename);
@@ -5238,7 +5238,7 @@
}
cString newinfo_fn;
- newinfo_fn.Set("%s%s.newinfo.dat", directory(), "lineage");
+ newinfo_fn.Set("%s%s.newinfo.dat", static_cast<const char*>(directory), "lineage");
ofstream& newinfo_fp = m_world->GetDataFileOFStream(newinfo_fn);
newinfo_fp << "# Legend:" << endl;
@@ -5617,7 +5617,7 @@
for (int mut_id = 0; mut_id < total_diffs; mut_id++) {
if ((combo_id >> mut_id) & 1) {
const int cur_pos = mut_positions[mut_id];
- test_sequence[cur_pos] = last_seq.GetData()[cur_pos];
+ test_sequence[cur_pos] = static_cast<const char*>(last_seq)[cur_pos];
diff_count++;
}
}
@@ -6053,9 +6053,9 @@
cString lineage_filename;
if (batch[cur_batch].IsLineage()) {
- lineage_filename.Set("%s%s.complexity.dat", directory(), "lineage");
+ lineage_filename.Set("%s%s.complexity.dat", static_cast<const char*>(directory), "lineage");
} else {
- lineage_filename.Set("%s%s.complexity.dat", directory(), "nonlineage");
+ lineage_filename.Set("%s%s.complexity.dat", static_cast<const char*>(directory), "nonlineage");
}
ofstream& lineage_fp = m_world->GetDataFileOFStream(lineage_filename);
@@ -6066,7 +6066,7 @@
// Construct this filename...
cString filename;
- filename.Set("%s%s.complexity.dat", directory(), genotype->GetName()());
+ filename.Set("%s%s.complexity.dat", static_cast<const char*>(directory), static_cast<const char*>(genotype->GetName()));
ofstream& fp = m_world->GetDataFileOFStream(filename);
lineage_fp << genotype->GetID() << " ";
@@ -6199,7 +6199,7 @@
// Construct filename...
cString filename;
- filename.Set("%spop%s.complexity.dat", directory(), file());
+ filename.Set("%spop%s.complexity.dat", static_cast<const char*>(directory), static_cast<const char*>(file));
ofstream& fp = m_world->GetDataFileOFStream(filename);
//////////////////////////////////////////////////////////
@@ -6280,21 +6280,7 @@
help_control.PrintHTML();
}
-void cAnalyze::CommandDocfile(cString cur_string)
-{
- cout << "Printing documentation files in: " << cur_string << endl;
-
- cHelpManager help_control;
- if (verbose >= nAnalyze::VERBOSE_ON) help_control.SetVerbose();
- while (cur_string.GetSize() > 0) {
- help_control.LoadFile(cur_string.PopWord());
- }
-
- help_control.PrintHTML();
-}
-
-
//////////////// Control...
void cAnalyze::VarSet(cString cur_string)
@@ -6562,7 +6548,7 @@
{
cout << "Running System Command: " << cur_string << endl;
- system(cur_string());
+ system(cur_string);
}
void cAnalyze::CommandInteractive(cString cur_string)
@@ -6764,12 +6750,11 @@
}
// Make sure the directory exists.
- FILE *fp = fopen ( directory(), "r" );
- if ( fp == 0 ){
- if ( errno == ENOENT ){
- cerr << "Directory '" << directory
- << "' does not exist. Creating..." << endl;
- if ( mkdir( directory(), (S_IRWXU|S_IRWXG|S_IRWXO) ) )
+ FILE *fp = fopen (directory, "r");
+ if ( fp == 0 ) {
+ if ( errno == ENOENT ) {
+ cerr << "Directory '" << directory << "' does not exist. Creating..." << endl;
+ if (mkdir(directory, (S_IRWXU|S_IRWXG|S_IRWXO)))
cerr << " Error creating '" << directory << "'" << endl;
}
else cerr << " Error opening '" << directory << "'" << endl;
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/analyze/cAnalyze.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -206,7 +206,6 @@
// Documentation...
void CommandHelpfile(cString cur_string);
- void CommandDocfile(cString cur_string);
// Control...
void VarSet(cString cur_string);
Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/analyze/cAnalyzeGenotype.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -547,8 +547,7 @@
// Tack on the current symbol...
cString symbol_string;
- symbol_string.Set("<b><font color=\"%s\">%c</font></b>",
- color(), symbol);
+ symbol_string.Set("<b><font color=\"%s\">%c</font></b>", static_cast<const char*>(color), symbol);
html_code += symbol_string;
}
}
Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/analyze/cAnalyzeGenotype.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -254,7 +254,7 @@
cString GetHTMLSequence() const;
cString GetMapLink() const {
- return cStringUtil::Stringf("<a href=\"tasksites.%s.html\">Phenotype Map</a>", GetName()());
+ return cStringUtil::Stringf("<a href=\"tasksites.%s.html\">Phenotype Map</a>", static_cast<const char*>(GetName()));
}
int GetNumTasks() const { return task_counts.GetSize(); }
Modified: development/source/analyze/cAnalyzeUtil.cc
===================================================================
--- development/source/analyze/cAnalyzeUtil.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/analyze/cAnalyzeUtil.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -291,7 +291,7 @@
cString con_name;
con_name.Set("classmgr/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
- cTestUtil::PrintGenome(world, con_genome, con_name());
+ cTestUtil::PrintGenome(world, con_genome, con_name);
if (con_genotype) {
@@ -391,7 +391,7 @@
world->GetStats().GetUpdate(), i );
fp << i << " " // 1 cell ID
- << creature_name() << " " // 2 name
+ << creature_name << " " // 2 name
<< genotype->GetLength() << " " // 3 length
<< genotype->GetTestFitness() << " " // 4 fitness (test-cpu)
<< organism->GetPhenotype().GetFitness() << " " // 5 fitness (actual)
@@ -409,7 +409,7 @@
else fp << endl;
if ( save_genotype ){
char filename[40];
- sprintf( filename, "classmgr/%s", creature_name() );
+ sprintf(filename, "classmgr/%s", static_cast<const char*>(creature_name));
cTestUtil::PrintGenome(world, genome, filename);
}
}
@@ -522,12 +522,12 @@
<< fave_testCPU/ (double) n << " " // 4 average test fitness
<< n << " " // 5 organism total
<< max_fitness << " " // 6 maximum fitness
- << max_f_name() << " " // 7 maxfit genotype name
+ << max_f_name << " " // 7 maxfit genotype name
<< endl;
if (save_max_f_genotype) {
char filename[40];
- sprintf( filename, "classmgr/%s", max_f_name() );
+ sprintf(filename, "classmgr/%s", static_cast<const char*>(max_f_name));
cTestUtil::PrintGenome(world, max_f_genotype->GetGenome(), filename);
}
@@ -646,18 +646,18 @@
sum_fitness += cur_genotype->GetTestFitness() * num_orgs;
sum_num_organisms += num_orgs;
- fp << cur_genotype->GetName()() << " " // 1 name
+ fp << cur_genotype->GetName() << " " // 1 name
<< cur_genotype->GetTestFitness() << " " // 2 fitness
<< num_orgs << " " // 3 abundance
<< cGenomeUtil::FindHammingDistance(reference_genome, genome) << " "
<< cGenomeUtil::FindEditDistance(reference_genome, genome) << " " // 5
- << genome.AsString()() << " " // 6 genome
+ << genome.AsString() << " " // 6 genome
<< endl;
// save into classmgr
if (save_creatures) {
char filename[40];
- sprintf( filename, "classmgr/%s", cur_genotype->GetName()() );
+ sprintf(filename, "classmgr/%s", static_cast<const char*>(cur_genotype->GetName()) );
cTestUtil::PrintGenome(world, genome, filename);
}
@@ -727,7 +727,7 @@
<< parent_sum_tasks_rewarded << " " // 6 parent number of tasks rewared
<< parent_sum_tasks_all << " " // 7 parent total num tasks done
<< test_info.GetColonyFitness() << " " // 8 genotype fitness
- << organism->GetGenotype()->GetName()() << " " // 9 genotype name
+ << organism->GetGenotype()->GetName() << " " // 9 genotype name
<< endl;
}
}
Modified: development/source/classification/cClassificationManager.cc
===================================================================
--- development/source/classification/cClassificationManager.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/classification/cClassificationManager.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -68,7 +68,7 @@
m_genotype_dom_time++;
if (m_genotype_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
cString filename;
- filename.Set("archive/%s", best_genotype->GetName()());
+ filename.Set("archive/%s", static_cast<const char*>(best_genotype->GetName()));
cTestUtil::PrintGenome(m_world, best_genotype->GetGenome(),
filename, best_genotype, m_world->GetStats().GetUpdate());
}
@@ -85,7 +85,7 @@
m_inject_dom_time++;
if (m_inject_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
cString filename;
- filename.Set("archive/%s", best_inject_genotype->GetName()());
+ filename.Set("archive/%s", static_cast<const char*>(best_inject_genotype->GetName()));
cTestUtil::PrintGenome(m_world, best_inject_genotype, best_inject_genotype->GetGenome(),
filename, m_world->GetStats().GetUpdate());
}
@@ -400,16 +400,16 @@
// Do the relevent statistics...
if (m_world->GetConfig().SPECIES_RECORDING.Get()) {
- m_world->GetStats().AddThreshold(in_genotype.GetID(), in_genotype.GetName()(),
+ m_world->GetStats().AddThreshold(in_genotype.GetID(), in_genotype.GetName(),
found_species->GetID());
} else {
- m_world->GetStats().AddThreshold(in_genotype.GetID(), in_genotype.GetName()());
+ m_world->GetStats().AddThreshold(in_genotype.GetID(), in_genotype.GetName());
}
// Print the genotype?
if (m_world->GetConfig().GENOTYPE_PRINT.Get()) {
cString filename;
- filename.Set("archive/%s", in_genotype.GetName()());
+ filename.Set("archive/%s", static_cast<const char*>(in_genotype.GetName()));
cTestUtil::PrintGenome(m_world, in_genotype.GetGenome(), filename,
&in_genotype, m_world->GetStats().GetUpdate());
}
Modified: development/source/classification/cLineage.cc
===================================================================
--- development/source/classification/cLineage.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/classification/cLineage.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -81,7 +81,7 @@
// is the genotype part of the map?
if ( cur == m_genotype_map.end() ) {
- cerr << "Removing creature from lineage whose genotype is not part of the lineage!\n " << genotype->GetName()() << " " << GetID() << endl;
+ cerr << "Removing creature from lineage whose genotype is not part of the lineage!\n " << genotype->GetName() << " " << GetID() << endl;
return false;
}
Modified: development/source/cpu/cHardwareStatusPrinter.cc
===================================================================
--- development/source/cpu/cHardwareStatusPrinter.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/cpu/cHardwareStatusPrinter.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -22,7 +22,7 @@
cString cHardwareStatusPrinter::Bonus(const cString &next_name)
{
- return cStringUtil::Stringf("%s (bonus instruction)", next_name());
+ return cStringUtil::Stringf("%s (bonus instruction)", static_cast<const char*>(next_name));
}
void cHardwareStatusPrinter::PrintStatus(cHardwareBase& hardware, const cString& next_name)
Modified: development/source/cpu/cTestUtil.cc
===================================================================
--- development/source/cpu/cTestUtil.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/cpu/cTestUtil.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -46,7 +46,7 @@
// @CAO Fix!!!!!!
if( fp.good() == false ) {
- cerr << "Unable to open output file '" << filename() << "'" << endl;
+ cerr << "Unable to open output file '" << filename << "'" << endl;
return;
}
@@ -146,7 +146,7 @@
// @CAO Fix!!!!!!
if( fp.good() == false ) {
- cerr << "Unable to open output file '" << filename() << "'" <<
+ cerr << "Unable to open output file '" << filename << "'" <<
endl;
return;
}
Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/event/cEventManager.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -955,7 +955,7 @@
void Process(){
cGenotype * dom = m_world->GetClassificationManager().GetBestGenotype();
cString filename(in_filename);
- if (filename == "") filename.Set("archive/%s", dom->GetName()());
+ if (filename == "") filename.Set("archive/%s", static_cast<const char*>(dom->GetName()));
cTestUtil::PrintGenome(m_world, dom->GetGenome(), filename, dom, m_world->GetStats().GetUpdate());
}
};
@@ -1018,7 +1018,7 @@
cInjectGenotype * dom = m_world->GetClassificationManager().GetBestInjectGenotype();
if (dom!=NULL) {
cString filename(in_filename);
- if (filename == "") filename.Set("archive/%s", dom->GetName()());
+ if (filename == "") filename.Set("archive/%s", static_cast<const char*>(dom->GetName()));
cTestUtil::PrintGenome(m_world, dom, dom->GetGenome(), filename, m_world->GetStats().GetUpdate()); }
}
};
@@ -1172,7 +1172,7 @@
}
///// load_population /////
void Process(){
- ifstream fp(fname());
+ ifstream fp(fname);
m_world->GetPopulation().LoadPopulation(fp);
}
};
@@ -1230,7 +1230,7 @@
}
///// load_clone /////
void Process(){
- ifstream fp(fname());
+ ifstream fp(fname);
m_world->GetPopulation().LoadClone(fp);
}
};
Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/main/cEnvironment.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -127,8 +127,7 @@
cString var_entry = desc.Pop(':');
cString var_name;
cString var_value;
- const cString var_type =
- cStringUtil::Stringf("reaction '%s' process", reaction->GetName()());
+ const cString var_type = cStringUtil::Stringf("reaction '%s' process", static_cast<const char*>(reaction->GetName()));
// Parse this entry.
if (!ParseSetting(var_entry, var_name, var_value, var_type)) return false;
@@ -225,8 +224,7 @@
cString var_entry = desc.Pop(':');
cString var_name;
cString var_value;
- const cString var_type =
- cStringUtil::Stringf("reaction '%s' requisite", reaction->GetName()());
+ const cString var_type = cStringUtil::Stringf("reaction '%s' requisite", static_cast<const char*>(reaction->GetName()));
// Parse this entry.
if (!ParseSetting(var_entry, var_name, var_value, var_type)) return false;
@@ -281,7 +279,7 @@
cString var_entry = cur_resource.Pop(':');
cString var_name;
cString var_value;
- const cString var_type = cStringUtil::Stringf("resource '%s'", name());
+ const cString var_type = cStringUtil::Stringf("resource '%s'", static_cast<const char*>(name));
// Parse this entry.
if (!ParseSetting(var_entry, var_name, var_value, var_type)) {
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/main/cPopulation.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -208,7 +208,7 @@
ifstream fp(fname);
if( !fp.good() ){
- cerr << "Error: Failed to load population file " << fname() << ". Exiting...\n" << endl;
+ cerr << "Error: Failed to load population file " << fname << ". Exiting...\n" << endl;
exit(2);
}
LoadPopulation(fp);
Modified: development/source/targets/avida-viewer/cEnvironmentScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cEnvironmentScreen.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/targets/avida-viewer/cEnvironmentScreen.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -167,7 +167,7 @@
}
SetBoldColor(COLOR_WHITE);
- Print(res_lib.GetSize()+3, 37, "%s", res_lib.GetResource(res_selection)->GetName().GetData());
+ Print(res_lib.GetSize()+3, 37, "%s", res_lib.GetResource(res_selection)->GetName());
Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+37, ":");
Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+38, " ");
@@ -210,7 +210,7 @@
offset++;
}
SetBoldColor(COLOR_WHITE);
- Print(rxn_lib.GetSize()+3, 37, "%s", rxn_lib.GetReaction(rxn_selection)->GetName().GetData());
+ Print(rxn_lib.GetSize()+3, 37, "%s", rxn_lib.GetReaction(rxn_selection)->GetName());
Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+37, ":");
Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+38, " ");
Modified: development/source/tools/CMakeLists.txt
===================================================================
--- development/source/tools/CMakeLists.txt 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/CMakeLists.txt 2006-01-20 13:46:47 UTC (rev 442)
@@ -2,7 +2,6 @@
cBlockStruct.cc
cChangeList.cc
cConstSchedule.cc
- cCountTracker.cc
cDataFile.cc
cDataFileManager.cc
cDataManager_Base.cc
Modified: development/source/tools/cChangeList.cc
===================================================================
--- development/source/tools/cChangeList.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cChangeList.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -11,7 +11,8 @@
#include "cChangeList.h"
-void cChangeList::ResizeClear(int capacity){
+void cChangeList::ResizeClear(int capacity)
+{
m_change_list.ResizeClear(capacity);
m_change_tracking.ResizeClear(capacity);
m_change_list.SetAll(0);
@@ -19,19 +20,10 @@
m_change_count = 0;
}
-cChangeList::cChangeList(int capacity)
-: m_change_count(0)
-, m_change_list(0)
-, m_change_tracking(0)
-{ ResizeClear(capacity); }
-
-int cChangeList::GetSize() const { return m_change_list.GetSize(); }
-
-int cChangeList::GetChangeCount() const { return m_change_count; }
-
// Note that decreasing size invalidates stored changes.
-void cChangeList::Resize(int capacity) {
- if (capacity < m_change_list.GetSize()){
+void cChangeList::Resize(int capacity)
+{
+ if (capacity < m_change_list.GetSize()) {
ResizeClear(capacity);
} else {
m_change_list.Resize(capacity);
@@ -39,18 +31,9 @@
}
}
-// Unsafe version : assumes index is within change count.
-int cChangeList::GetChangeAt(int index) const {
- return m_change_list[index];
-}
-
-// Safe version : returns -1 if index is outside change count.
-int cChangeList::CheckChangeAt(int index) const {
- return (index < m_change_count) ? ((int) GetChangeAt(index)) : (-1);
-}
-
// Unsafe version : assumes changed_index is within capacity.
-void cChangeList::MarkChange(int changed_index) {
+void cChangeList::MarkChange(int changed_index)
+{
if (!m_change_tracking[changed_index]) {
m_change_tracking[changed_index] = true;
m_change_list[m_change_count] = changed_index;
@@ -60,14 +43,16 @@
// Safe version : will resize to accommodate changed_index greater
// than capacity.
-void cChangeList::PushChange(int changed_index) {
+void cChangeList::PushChange(int changed_index)
+{
if (m_change_list.GetSize() <= changed_index) {
Resize(changed_index + 1);
}
MarkChange(changed_index);
}
-void cChangeList::Reset() {
+void cChangeList::Reset()
+{
for (int i = 0; i < m_change_count; i++) {
m_change_tracking[m_change_list[i]] = false;
}
Modified: development/source/tools/cChangeList.h
===================================================================
--- development/source/tools/cChangeList.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cChangeList.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -21,7 +21,8 @@
* registered changes.
**/
-class cChangeList {
+class cChangeList
+{
protected:
/*
Note that size of m_change_list is size of m_change_tracking, and that
@@ -39,41 +40,30 @@
tArray<bool> m_change_tracking;
public:
+ explicit cChangeList(int capacity = 0)
+ : m_change_count(0), m_change_list(0), m_change_tracking(0)
+ {
+ ResizeClear(capacity);
+ }
+ ~cChangeList() { ; }
+
void ResizeClear(int capacity);
- // Constructor.
- explicit cChangeList(int capacity = 0);
+ int GetSize() const { return m_change_list.GetSize(); }
+ int GetChangeCount() const { return m_change_count; }
- //// Assignment operator.
- //cChangeList & operator= (const cChangeList & rhs) {
- // m_change_list = rhs.m_change_list;
- // m_change_tracking = rhs.m_change_tracking;
- // m_change_count = rhs.m_change_count;
- //}
-
- //// Copy constructor.
- //explicit cChangeList(const cChangeList & rhs) : cChangeList(0) {
- // this->operator=(rhs);
- //}
-
- // Destructor.
- //virtual ~cChangeList(){}
-
- // Interface Methods ///////////////////////////////////////////////////////
-
- int GetSize() const;
-
- int GetChangeCount() const;
-
// Note that decreasing size invalidates stored changes.
void Resize(int capacity);
// Unsafe version : assumes index is within change count.
- int GetChangeAt(int index) const;
+ int GetChangeAt(int index) const { return m_change_list[index]; }
// Safe version : returns -1 if index is outside change count.
- int CheckChangeAt(int index) const;
-
+ int CheckChangeAt(int index) const
+ {
+ return (index < m_change_count) ? ((int) GetChangeAt(index)) : (-1);
+ }
+
// Unsafe version : assumes changed_index is within capacity.
void MarkChange(int changed_index);
Modified: development/source/tools/cConstSchedule.cc
===================================================================
--- development/source/tools/cConstSchedule.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cConstSchedule.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -14,17 +14,6 @@
#include "cMerit.h"
-cConstSchedule::cConstSchedule(int _item_count)
- : cSchedule(_item_count), is_active(_item_count)
-{
- last_id = 0;
- is_active.SetAll(false);
-}
-
-cConstSchedule::~cConstSchedule()
-{
-}
-
bool cConstSchedule::OK()
{
assert(last_id == 0 || last_id < item_count); // invalid last_id
Modified: development/source/tools/cConstSchedule.h
===================================================================
--- development/source/tools/cConstSchedule.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cConstSchedule.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -24,16 +24,24 @@
class cMerit;
-class cConstSchedule : public cSchedule {
+class cConstSchedule : public cSchedule
+{
private:
int last_id;
tArray<bool> is_active;
+
+ cConstSchedule(); // @not_implemented
+
public:
- cConstSchedule(int _item_count);
- ~cConstSchedule();
+ cConstSchedule(int _item_count)
+ : cSchedule(_item_count), last_id(0), is_active(_item_count)
+ {
+ is_active.SetAll(false);
+ }
+ ~cConstSchedule() { ; }
bool OK();
- void Adjust(int item_id, const cMerit & merit);
+ void Adjust(int item_id, const cMerit& merit);
int GetNextID();
};
Deleted: development/source/tools/cCountTracker.cc
===================================================================
--- development/source/tools/cCountTracker.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cCountTracker.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -1,36 +0,0 @@
-/*
- * cCountTracker.cc
- * Avida
- *
- * Created by David on 12/2/05.
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- */
-
-#include "cCountTracker.h"
-
-
-void cCountTracker::Inc()
-{
- cur_count++;
- total_count++;
-}
-
-void cCountTracker::Dec()
-{
- cur_count--;
-}
-
-void cCountTracker::Next()
-{
- last_count = cur_count;
- cur_count = 0;
-}
-
-void cCountTracker::Clear()
-{
- cur_count = 0;
- last_count = 0;
- total_count = 0;
-}
Modified: development/source/tools/cCountTracker.h
===================================================================
--- development/source/tools/cCountTracker.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cCountTracker.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -11,11 +11,13 @@
#ifndef cCountTracker_h
#define cCountTracker_h
-class cCountTracker {
+class cCountTracker
+{
private:
int cur_count;
int last_count;
int total_count;
+
public:
cCountTracker() { Clear(); }
~cCountTracker() { ; }
@@ -24,10 +26,10 @@
int GetLast() const { return last_count; }
int GetTotal() const { return total_count; }
- void Inc();
- void Dec();
- void Next();
- void Clear();
+ void Inc() { cur_count++; total_count++; }
+ void Dec() { cur_count--; }
+ void Next() { last_count = cur_count; cur_count = 0; }
+ void Clear() { cur_count = last_count = total_count = 0; }
};
#endif
Modified: development/source/tools/cDataFile.cc
===================================================================
--- development/source/tools/cDataFile.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDataFile.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -20,21 +20,8 @@
using namespace std;
-void cDataFile::Init()
+cDataFile::cDataFile(cString& name) : m_name(name), num_cols(0), m_descr_written(false)
{
- m_descr_written = false;
- num_cols = 0;
-}
-
-cDataFile::cDataFile()
-{
- Init();
-}
-
-cDataFile::cDataFile(cString name) : m_name(name)
-{
- Init();
-
//if (fopen(name,"r")) {
// cout << "File " << name() << " exists and is being overwritten" << endl;
//}
Modified: development/source/tools/cDataFile.h
===================================================================
--- development/source/tools/cDataFile.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDataFile.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -23,11 +23,9 @@
* @ref cFile.
*/
-class cDataFile {
-
+class cDataFile
+{
private:
- cDataFile(const cDataFile &); // not implemented.
-private:
cString m_name;
cString m_data;
cString m_descr;
@@ -37,12 +35,11 @@
std::ofstream m_fp;
- void Init();
+ cDataFile(const cDataFile&); // @not_implemented.
+ cDataFile& operator=(const cDataFile&); // @not_implemented
+
public:
- /**
- * The empty constructor does nothing.
- **/
- cDataFile();
+ cDataFile() : num_cols(0), m_descr_written(false) { ; }
/**
* This constructor opens a file of the given name, and makes sure
@@ -50,17 +47,17 @@
*
* @param _name The name of the file to open.
**/
- cDataFile(cString name);
+ cDataFile(cString& name);
/**
* The desctructor automatically closes the file.
**/
- ~cDataFile(){ m_fp.close(); }
+ ~cDataFile() { m_fp.close(); }
/**
* @return The file name used
**/
- const cString & GetName() const { return m_name; }
+ const cString& GetName() const { return m_name; }
/**
* @return A bool that indicates whether the file is actually usable.
@@ -85,9 +82,9 @@
* will be written only once, before the first data line has been finished.
**/
- void Write( double x, const char * descr );
- void Write( int i, const char * descr );
- void Write( const char * data_str, const char * descr );
+ void Write( double x, const char* descr );
+ void Write( int i, const char* descr );
+ void Write( const char* data_str, const char* descr );
void WriteBlockElement (double x, int element, int x_size );
void WriteBlockElement (int i, int element, int x_size );
@@ -96,26 +93,26 @@
* written if the first data line hasn't been completed (Endl() hasn't
* been called. This allows to output initial comments into a file.
**/
- void WriteComment( const char * descr );
+ void WriteComment( const char* descr );
/**
* Same as WriteComment, but doesn't automatically include the # in the
* front of the line. This should only be used in special circumstances
* where something outside of a typical comment needs to be at the top.
**/
- void WriteRawComment( const char * descr );
+ void WriteRawComment( const char* descr );
/**
* Writes text string any where in the data file. This should only be used
* in special circumstances where something outside of a typical comment
* needs to be placed in the file.
**/
- void WriteRaw( const char * descr );
+ void WriteRaw( const char* descr );
/**
* Writes the description for a single column; keeps track of column numbers.
**/
- void WriteColumnDesc(const char * descr );
+ void WriteColumnDesc(const char* descr );
/**
* Writes the current time into the data file. The time string is only
@@ -144,7 +141,7 @@
/**
* This function makes sure that all cached data is written to the disk.
**/
- void Flush(){ m_fp.flush(); }
+ void Flush() { m_fp.flush(); }
};
#endif
Modified: development/source/tools/cDataFileManager.cc
===================================================================
--- development/source/tools/cDataFileManager.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDataFileManager.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -29,7 +29,8 @@
// If it hasn't been found, create it...
if (!m_datafiles.Find(name, found_file)) {
- found_file = new cDataFile(m_target_dir + name);
+ cString filename = m_target_dir + name;
+ found_file = new cDataFile(filename);
m_datafiles.Add(name, found_file);
}
Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDataFileManager.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -37,10 +37,10 @@
cString m_target_dir;
tDictionary<cDataFile*> m_datafiles;
- cDataFile* InternalFind(const cString & name);
+ cDataFile* InternalFind(const cString& name);
- // disabled copy constructor.
- cDataFileManager(const cDataFileManager &);
+ cDataFileManager(const cDataFileManager&); // @not_implemented
+ cDataFileManager& operator=(const cDataFileManager&); // @not_implemented
public:
inline cDataFileManager(cString target_dir = "");
Modified: development/source/tools/cDataManager_Base.h
===================================================================
--- development/source/tools/cDataManager_Base.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDataManager_Base.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -22,6 +22,12 @@
class cDataManager_Base {
private:
cString filetype;
+
+
+ cDataManager_Base(); // @not_implemented
+ cDataManager_Base(const cDataManager_Base&); // @not_implemented
+ cDataManager_Base& operator=(const cDataManager_Base&); // @not_implemented
+
public:
cDataManager_Base(const cString & in_filetype) : filetype(in_filetype) { ; }
virtual ~cDataManager_Base() { ; }
Modified: development/source/tools/cDefaultMessageDisplay.cc
===================================================================
--- development/source/tools/cDefaultMessageDisplay.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDefaultMessageDisplay.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -15,7 +15,7 @@
using namespace std;
-void cDefaultMessageDisplay::out(cString& final_msg) { *_out << final_msg << endl; _out->flush(); }
+void cDefaultMessageDisplay::out(cString& final_msg) { *m_out << final_msg << endl; m_out->flush(); }
/*
default instantiations of cDefaultMessageDisplay...
Modified: development/source/tools/cDefaultMessageDisplay.h
===================================================================
--- development/source/tools/cDefaultMessageDisplay.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDefaultMessageDisplay.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -34,11 +34,18 @@
class cString;
-class cDefaultMessageDisplay : public cMessageDisplay {
+class cDefaultMessageDisplay : public cMessageDisplay
+{
private:
- std::ostream* _out;
+ std::ostream* m_out;
+
+
+ cDefaultMessageDisplay(); // @not_implemented
+ cDefaultMessageDisplay(const cDefaultMessageDisplay&); // @not_implemented
+ cDefaultMessageDisplay& operator=(const cDefaultMessageDisplay&); // @not_implemented
+
public:
- cDefaultMessageDisplay(std::ostream* stream):_out(stream){}
+ cDefaultMessageDisplay(std::ostream* stream) : m_out(stream) { ; }
void out(cString& final_msg);
};
Modified: development/source/tools/cDoubleSum.h
===================================================================
--- development/source/tools/cDoubleSum.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cDoubleSum.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -25,9 +25,9 @@
public:
static const double INF_ERR; // Value Returned by StdError if Infinate
- cDoubleSum(){ Clear(); }
+ cDoubleSum() { Clear(); }
- void Clear(){ s1=0; s2=0; s3=0; s4=0; n=0; }
+ void Clear() { s1 = s2 = s3 = s4 = n = 0; }
double Count() const { return n; }
double N() const { return n; }
Modified: development/source/tools/cFile.cc
===================================================================
--- development/source/tools/cFile.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cFile.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -23,13 +23,13 @@
bool cFile::Open(cString _fname, ios::openmode flags)
{
if( IsOpen() ) Close(); // If a file is already open, clost it first.
- fp.open(_fname(), flags); // Open the new file.
+ fp.open(_fname, flags); // Open the new file.
// Test if there was an error, and if so, try again!
int err_id = fp.fail();
if( err_id ){
fp.clear();
- fp.open(_fname(), flags);
+ fp.open(_fname, flags);
}
// If there is still an error, determine its type and report it.
Modified: development/source/tools/cFile.h
===================================================================
--- development/source/tools/cFile.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cFile.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -24,18 +24,19 @@
* Its main usage is for the class @ref cInitFile.
**/
-class cFile {
+class cFile
+{
private:
- cFile(const cFile &);
+ cFile(const cFile&); // @not_implemented
+ cFile& operator=(const cFile&); // @not_implemented
+
protected:
std::fstream fp;
cString filename;
bool is_open; // Have we successfully opened this file?
bool verbose; // Should file be verbose about warnings to users?
+
public:
- /**
- * The empty constructor does nothing.
- **/
cFile() : filename(""), is_open(false), verbose(false) { ; }
/**
@@ -53,7 +54,7 @@
/**
* @return The name of the file currently open.
**/
- const cString & GetFilename() const { return filename; }
+ const cString& GetFilename() const { return filename; }
/**
* Open a file of the given name. If another file was open previously,
@@ -82,8 +83,6 @@
bool Fail() const { return (fp.fail()); }
bool Good() const { return (fp.good()); }
bool Eof() const { return (fp.eof()); }
- // int AtStart();
- // int AtEnd();
void SetVerbose(bool _v=true) { verbose = _v; }
};
Modified: development/source/tools/cHelpEntry.h
===================================================================
--- development/source/tools/cHelpEntry.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cHelpEntry.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -34,8 +34,7 @@
virtual bool IsAlias() const = 0;
- cString GetHTMLFilename() const
- { return cStringUtil::Stringf("help.%s.html", GetKeyword()()); }
+ cString GetHTMLFilename() const { return cStringUtil::Stringf("help.%s.html", static_cast<const char*>(GetKeyword())); }
};
#endif
Modified: development/source/tools/cHelpType.cc
===================================================================
--- development/source/tools/cHelpType.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cHelpType.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -100,12 +100,10 @@
cerr << " Warning: unknown help keyword \""
<< keyword << "\"." << endl;
}
- new_word.Set("<a href=\"help.%s.html\">%s</a>%c",
- keyword(), keyword(), end_char);
+ new_word.Set("<a href=\"help.%s.html\">%s</a>%c", static_cast<const char*>(keyword), static_cast<const char*>(keyword), end_char);
}
else {
- new_word.Set("<a href=\"%s\">%s</a>%c",
- found_entry->GetHTMLFilename()(), keyword(), end_char);
+ new_word.Set("<a href=\"%s\">%s</a>%c", static_cast<const char*>(found_entry->GetHTMLFilename()), static_cast<const char*>(keyword), end_char);
}
// Rebuild the description with the new word...
Modified: development/source/tools/cInitFile.h
===================================================================
--- development/source/tools/cInitFile.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cInitFile.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -30,10 +30,9 @@
* A class to handle initialization files.
**/
-class cInitFile : public cFile {
+class cInitFile : public cFile
+{
private:
- cInitFile(const cInitFile &);
-private:
struct sFileLineInfo {
cString line;
int line_num;
@@ -46,6 +45,11 @@
cStringList file_format;
int active_line;
+
+
+ cInitFile(const cInitFile&); // @not_implemented
+ cInitFile& operator=(const cInitFile&); // @not_implemented
+
public:
/**
* The empty constructor constructs an object that is in a clean
Modified: development/source/tools/cIntSum.h
===================================================================
--- development/source/tools/cIntSum.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cIntSum.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -14,7 +14,8 @@
#include <math.h>
#include <limits.h>
-class cIntSum {
+class cIntSum
+{
private:
long s1; // Sum (x)
long s2; // Sum of squares (x^2)
@@ -25,9 +26,9 @@
public:
static const double INF_ERR; // Value Returned by StdError if Infinate
- cIntSum(){ Clear(); }
+ cIntSum() { Clear(); }
- void Clear(){ s1=0; s2=0; s3=0; s4=0; n=0; }
+ void Clear() { s1 = s2 = s3 = s4 = n = 0; }
long Count() const { return n; }
long N() const { return n; }
@@ -39,27 +40,18 @@
long S3() const { return s3; }
long S4() const { return s4; }
- double Average() const { return ( n >1 ) ? ((double)s1/n) : 0; }
+ double Average() const { return (n > 1) ? ((double)s1/n) : 0; }
- double Variance() const { return ( n > 1 ) ?
- (s2 - s1*s1/(double)n) / (double)(n-1) : INF_ERR; }
- //n*(s2/n - s1/n*s1/n) / (n-1) : INF_ERR; }
+ double Variance() const { return (n > 1) ? (s2 - s1*s1/(double)n) / (double)(n-1) : INF_ERR; }
double StdDeviation() const { return sqrt(Variance()); }
- double StdError() const { return (n > 1) ?
- sqrt(s2 / (double)(n * (n-1))) : INF_ERR; }
+ double StdError() const { return (n > 1) ? sqrt(s2 / (double)(n * (n-1))) : INF_ERR; }
- double Skewness() const { return ( n > 2 ) ?
- (n*s3 - 3*s2*s1 + 2*s1*s1*s1/(double)n) / (double)((n-1)*(n-2)) : INF_ERR; }
- //n*n*(s3/n - 3*s2/n*s1/n + 2*s1/n*s1/n*s1/n)/((n-1)*(n-2)) : INF_ERR; }
+ double Skewness() const { return (n > 2) ? (n*s3 - 3*s2*s1 + 2*s1*s1*s1/(double)n) / (double)((n-1)*(n-2)) : INF_ERR; }
+ double Kurtosis() const
+ {
+ return (n > 3) ? (n+1)*(n*s4 - 4*s3*s1 + 6*s2*s1*s1/(double)n - 3*s1*s1*s1/(double)n*s1/(double)n) / (double)((n-1)*(n-2)*(n-3)) : INF_ERR;
+ }
- double Kurtosis() const { return ( n > 3 ) ?
- //n*n*(n+1)*(s4/n - 4*s3/n*s1/n + 6*s2/n*s1/n*s1/n -
- //3*s1/n*s1/n*s1/n*s1/n)/((n-1)*(n-2)*(n-3)) :
- (n+1)*(n*s4 - 4*s3*s1 + 6*s2*s1*s1/(double)n -
- 3*s1*s1*s1/(double)n*s1/(double)n) /
- (double)((n-1)*(n-2)*(n-3)) :
- INF_ERR; }
-
// Notation Shortcuts
double Ave() const { return Average(); }
double Var() const { return Variance(); }
@@ -67,7 +59,8 @@
double Skw() const { return Skewness(); }
- void Add(long value, long weight=1){
+ void Add(long value, long weight = 1)
+ {
long w_val = value * weight;
n += weight;
s1 += w_val;
@@ -76,7 +69,8 @@
s4 += w_val * w_val * w_val * w_val;
}
- void Subtract(long value, long weight=1){
+ void Subtract(long value, long weight=1)
+ {
long w_val = value * weight;
n -= weight;
s1 -= w_val;
Modified: development/source/tools/cIntegratedSchedule.h
===================================================================
--- development/source/tools/cIntegratedSchedule.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cIntegratedSchedule.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -32,7 +32,8 @@
class cIntegratedScheduleNode;
class cMerit;
-class cIntegratedSchedule : public cSchedule {
+class cIntegratedSchedule : public cSchedule
+{
private:
tArray<cIntegratedScheduleNode *> node_array;
int num_active_nodes;
@@ -41,6 +42,11 @@
void InsertNode(int node_id);
void RemoveNode(int node_id);
void ResizeNodes(int new_size);
+
+ cIntegratedSchedule(); // @not_implemented
+ cIntegratedSchedule(const cIntegratedSchedule&); // @not_implemented
+ cIntegratedSchedule& operator=(const cIntegratedSchedule&); // @not_implemented
+
public:
cIntegratedSchedule(int _item_count);
~cIntegratedSchedule();
Modified: development/source/tools/cIntegratedScheduleNode.cc
===================================================================
--- development/source/tools/cIntegratedScheduleNode.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cIntegratedScheduleNode.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -11,33 +11,6 @@
#include "cIntegratedScheduleNode.h"
-cIntegratedScheduleNode::cIntegratedScheduleNode(int _item_count, int in_id)
- : active_array(_item_count)
-{
- // Store the input variables.
-
- node_id = in_id;
-
- // Initialize the remaining variables.
-
- for (int i = 0; i < active_array.GetSize(); i++) {
- active_array[i] = 0;
- }
- first_entry = -1;
- active_entry = -1;
- size = 0;
- process_size = 1;
- process_count = 0;
- execute = true;
- next = NULL;
- prev = NULL;
-}
-
-cIntegratedScheduleNode::~cIntegratedScheduleNode()
-{
-}
-
-
bool cIntegratedScheduleNode::OK()
{
bool result = true;
Modified: development/source/tools/cIntegratedScheduleNode.h
===================================================================
--- development/source/tools/cIntegratedScheduleNode.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cIntegratedScheduleNode.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -30,7 +30,8 @@
* each item should be included in.
**/
-class cIntegratedScheduleNode {
+class cIntegratedScheduleNode
+{
private:
tArray<int> active_array; // Each cell in this array corressponds to the
// item with the same ID. If creature is not in the
@@ -48,11 +49,21 @@
int process_count; // Number of times this node has been executed.
bool execute; // Should this node execute or pass?
- cIntegratedScheduleNode * next;
- cIntegratedScheduleNode * prev;
+ cIntegratedScheduleNode* next;
+ cIntegratedScheduleNode* prev;
+
+
+ cIntegratedScheduleNode(const cIntegratedScheduleNode&); // @not_implemented
+ cIntegratedScheduleNode& operator=(const cIntegratedScheduleNode&); // @not_implemented
+
public:
- cIntegratedScheduleNode(int _item_count = 0, int in_id = -1);
- ~cIntegratedScheduleNode();
+ cIntegratedScheduleNode(int _item_count = 0, int in_id = -1)
+ : active_array(_item_count), first_entry(-1), active_entry(-1), node_id(in_id), size(0)
+ , process_size(1), process_count(0), execute(true), next(NULL), prev(NULL)
+ {
+ active_array.SetAll(0);
+ }
+ ~cIntegratedScheduleNode() { ; }
void Insert(int item_id);
void Remove(int item_id);
Modified: development/source/tools/cMerit.h
===================================================================
--- development/source/tools/cMerit.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cMerit.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -16,7 +16,8 @@
#include <limits.h>
#include <assert.h>
-class cMerit {
+class cMerit
+{
protected:
int bits;
unsigned int base;
@@ -26,21 +27,24 @@
void UpdateValue(double in_value);
public:
- cMerit() : bits(0), base(0), offset(0), value(0) {;}
+ cMerit() : bits(0), base(0), offset(0), value(0) { ; }
explicit cMerit(const int in_value){ UpdateValue(in_value); }
explicit cMerit(const unsigned int in_value){ UpdateValue(in_value); }
explicit cMerit(const double in_value){ UpdateValue(in_value); }
+ cMerit(const cMerit& merit) { *this = merit; }
- bool OK() const ;
+ bool OK() const;
- void operator=(const cMerit & _merit){
+ void operator=(const cMerit & _merit)
+ {
bits = _merit.bits;
base = _merit.base;
offset = _merit.offset;
- value = _merit.value; }
+ value = _merit.value;
+ }
- void operator=(double _merit){ UpdateValue(_merit); }
+ void operator=(double _merit) { UpdateValue(_merit); }
void operator+=(const cMerit & _m){ UpdateValue(value + _m.GetDouble()); }
int operator>(const cMerit & _m) const { return value > _m.GetDouble(); }
Modified: development/source/tools/cProbSchedule.h
===================================================================
--- development/source/tools/cProbSchedule.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cProbSchedule.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -26,10 +26,16 @@
class cMerit;
class cWorld;
-class cProbSchedule : public cSchedule {
+class cProbSchedule : public cSchedule
+{
private:
cWorld* m_world;
cWeightedIndex chart;
+
+
+ cProbSchedule(const cProbSchedule&); // @not_implemented
+ cProbSchedule& operator=(const cProbSchedule&); // @not_implemented
+
public:
cProbSchedule(cWorld* world, int num_cells);
~cProbSchedule();
Modified: development/source/tools/cRandom.h
===================================================================
--- development/source/tools/cRandom.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cRandom.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -21,7 +21,41 @@
template <class T> class tArray;
-class cRandom {
+class cRandom
+{
+private:
+ // Internal memebers
+ int seed;
+ int original_seed;
+ int inext;
+ int inextp;
+ int ma[56];
+ int use_count;
+
+ // Constants ////////////////////////////////////////////////////////////////
+ // Statistical Approximation
+ static const unsigned int _BINOMIAL_TO_NORMAL; //if < n*p*(1-p)
+ static const unsigned int _BINOMIAL_TO_POISSON; //if < n && !Normal approx
+ // Engine
+ static const unsigned int _RAND_MBIG;
+ static const unsigned int _RAND_MSEED;
+ // Number Generation
+ static const double _RAND_FAC;
+ static const double _RAND_mP_FAC;
+ static const double _RAND_uP_FAC;
+
+ // Members & functions for stat functions
+ double expRV; // Exponential Random Variable for the randNormal function
+
+
+ // Internal functions
+ void init(); // Setup (called by ResetSeed(in_seed);
+ void initStatFunctions();
+
+ // Basic Random number
+ // Returns a random number [0,_RAND_MBIG)
+ inline unsigned int Get();
+
public:
/**
* Set up the random generator object.
@@ -29,7 +63,7 @@
* A negative seed means that the random number generator gets its
* seed from the actual system time.
**/
- cRandom(const int in_seed=-1);
+ cRandom(const int in_seed = -1);
inline int GetUseCount() { return use_count; }
@@ -37,12 +71,12 @@
/**
* @return The seed that was actually used to start the random sequence.
**/
- inline int GetSeed(){ return seed; }
+ inline int GetSeed() { return seed; }
/**
* @return The seed that was originally provided by the user.
**/
- inline int GetOriginalSeed(){ return original_seed; }
+ inline int GetOriginalSeed() { return original_seed; }
/**
* Starts a new sequence of pseudo random numbers.
@@ -61,7 +95,7 @@
*
* @return The pseudo random number.
**/
- inline double GetDouble(){ return Get()*_RAND_FAC; }
+ double GetDouble() { return Get() * _RAND_FAC; }
/**
* Generate a double between 0 and a given number.
@@ -69,7 +103,7 @@
* @return The pseudo random number.
* @param max The upper bound for the random numbers (will never be returned).
**/
- inline double GetDouble(const double max){ return GetDouble() * max;}
+ double GetDouble(const double max) { return GetDouble() * max; }
/**
* Generate a double out of a given interval.
@@ -78,8 +112,7 @@
* @param min The lower bound for the random numbers.
* @param max The upper bound for the random numbers (will never be returned).
**/
- inline double GetDouble(const double min, const double max){
- return GetDouble()*(max-min)+min;}
+ double GetDouble(const double min, const double max) { return GetDouble() * (max - min) + min; }
/**
* Generate an unsigned int.
@@ -87,8 +120,7 @@
* @return The pseudo random number.
* @param max The upper bound for the random numbers (will never be returned).
**/
- inline unsigned int GetUInt(const unsigned int max){
- return (int) (GetDouble()*max);}
+ unsigned int GetUInt(const unsigned int max) { return (int) (GetDouble() * max); }
/**
* Generate an unsigned int out of an interval.
@@ -97,8 +129,7 @@
* @param min The lower bound for the random numbers.
* @param max The upper bound for the random numbers (will never be returned).
**/
- inline unsigned int GetUInt(const unsigned int min, const unsigned int max){
- return GetUInt(max - min) + min; }
+ unsigned int GetUInt(const unsigned int min, const unsigned int max) { return GetUInt(max - min) + min; }
/**
* Generate an int out of an interval.
@@ -107,24 +138,17 @@
* @param min The lower bound for the random numbers.
* @param max The upper bound for the random numbers (will never be returned).
**/
- inline int GetInt(const int max){
- return (int)GetUInt(max); }
- inline int GetInt(const int min, const int max){
- return ((int)GetUInt(max - min)) + min; }
+ int GetInt(const int max) { return (int)GetUInt(max); }
+ int GetInt(const int min, const int max) { return ((int)GetUInt(max - min)) + min; }
// Random Event Generation //////////////////////////////////////////////////
// P(p) => if p < [0,1) random variable
- inline bool P(const double _p){
- return (Get()<(_p*_RAND_MBIG));}
- inline bool mP(const double _p){ // p = _p*10^-3
- return (Get()<_RAND_mP_FAC && Get()<(_p*_RAND_MBIG));}
- inline bool uP(const double _p){ // p = _p*10^-6
- return (Get()<_RAND_uP_FAC && Get()<(_p*_RAND_MBIG));}
- inline bool pP(const double _p){ // p = _p*10^-6
- return (Get()<_RAND_uP_FAC && Get()<_RAND_uP_FAC &&
- Get()<(_p*_RAND_MBIG));}
+ bool P(const double _p) { return (Get() < (_p * _RAND_MBIG));}
+ bool mP(const double _p) { return (Get() < _RAND_mP_FAC && Get() < (_p * _RAND_MBIG)); } // p = _p*10^-3
+ bool uP(const double _p) { return (Get() < _RAND_uP_FAC && Get() < (_p * _RAND_MBIG)); } // p = _p*10^-6
+ bool pP(const double _p) { return (Get() < _RAND_uP_FAC && Get() < _RAND_uP_FAC && Get() < (_p * _RAND_MBIG)); } // p = _p*10^-6
// Other neat stuff /////////////////////////////////////////////////////////
@@ -148,17 +172,15 @@
* Generate a random variable drawn from a distribution with given
* mean and variance.
**/
- inline double GetRandNormal(const double mean, const double variance){
- return mean+GetRandNormal()*sqrt(variance);
- }
+ double GetRandNormal(const double mean, const double variance) { return mean + GetRandNormal() * sqrt(variance); }
/**
* Generate a random variable drawn from a Poisson distribution.
**/
- inline unsigned int GetRandPoisson(const double n, double p) {
+ unsigned int GetRandPoisson(const double n, double p) {
// Optimizes for speed and calculability using symetry of the distribution
- if( p>.5 ) return (unsigned int)n-GetRandPoisson(n*(1-p));
- else return GetRandPoisson(n*p);
+ if (p > .5) return (unsigned int)n - GetRandPoisson(n * (1 - p));
+ else return GetRandPoisson(n * p);
}
/**
@@ -185,53 +207,20 @@
* @see cRandom::GetFullRandBinomial
**/
unsigned int GetRandBinomial(const double n, const double p); // Approx
-
-
- // Internals ////////////////////////////////////////////////////////////////
-private:
- // Internal memebers
- int seed;
- int original_seed;
- int inext;
- int inextp;
- int ma[56];
- int use_count;
-
- // Constants ////////////////////////////////////////////////////////////////
- // Statistical Approximation
- static const unsigned int _BINOMIAL_TO_NORMAL; //if < n*p*(1-p)
- static const unsigned int _BINOMIAL_TO_POISSON; //if < n && !Normal approx
- // Engine
- static const unsigned int _RAND_MBIG;
- static const unsigned int _RAND_MSEED;
- // Number Generation
- static const double _RAND_FAC;
- static const double _RAND_mP_FAC;
- static const double _RAND_uP_FAC;
-
- // Members & functions for stat functions
- double expRV; // Exponential Random Variable for the randNormal function
-
- // Internal functions
- void init(); // Setup (called by ResetSeed(in_seed);
- void initStatFunctions();
-
- // Basic Random number
- // Returns a random number [0,_RAND_MBIG)
- inline unsigned int Get(){
- // use_count++; // Turn this on if random uses need to be tracked.
-
- if (++inext == 56) inext = 0;
- if (++inextp == 56) inextp = 0;
- int mj = ma[inext] - ma[inextp];
- if (mj < 0) mj += _RAND_MBIG;
- ma[inext] = mj;
- return mj;
- }
-
};
-inline unsigned int cRandom::MutateByte(unsigned int value) {
+inline unsigned int cRandom::Get()
+{
+ if (++inext == 56) inext = 0;
+ if (++inextp == 56) inextp = 0;
+ int mj = ma[inext] - ma[inextp];
+ if (mj < 0) mj += _RAND_MBIG;
+ ma[inext] = mj;
+ return mj;
+}
+
+inline unsigned int cRandom::MutateByte(unsigned int value)
+{
int byte_pos = 8 * GetUInt(4);
int new_byte = GetUInt(256);
value &= ~(255 << byte_pos);
@@ -239,19 +228,22 @@
return value;
}
-inline unsigned int cRandom::ClearByte(unsigned int value) {
+inline unsigned int cRandom::ClearByte(unsigned int value)
+{
int byte_pos = 8 * GetUInt(4);
value &= ~(255 << byte_pos);
return value;
}
-inline unsigned int cRandom::MutateBit(unsigned int value) {
+inline unsigned int cRandom::MutateBit(unsigned int value)
+{
int bit_pos = GetUInt(32);
value ^= (1 << bit_pos);
return value;
}
-inline unsigned int cRandom::MutateBit(unsigned int value, int in_byte) {
+inline unsigned int cRandom::MutateBit(unsigned int value, int in_byte)
+{
int bit_pos = (in_byte) * 8 + GetUInt(8);
value ^= (1 << bit_pos);
return value;
Modified: development/source/tools/cRunningAverage.h
===================================================================
--- development/source/tools/cRunningAverage.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cRunningAverage.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -13,9 +13,10 @@
#include <math.h>
-class cRunningAverage {
+class cRunningAverage
+{
private:
- double *m_values; // Array of actual values
+ double* m_values; // Array of actual values
double m_s1; // average
double m_s2; // sum of squares
int m_window_size; // Size of sliding window
@@ -23,16 +24,17 @@
int m_n;
- cRunningAverage();
- cRunningAverage( const cRunningAverage & );
- cRunningAverage & operator=( const cRunningAverage & );
+ cRunningAverage(); // @not_implemented
+ cRunningAverage(const cRunningAverage&); // @not_implemented
+ cRunningAverage& operator=(const cRunningAverage&); // @not_implemented
+
public:
- cRunningAverage( int window_size );
+ cRunningAverage(int window_size);
~cRunningAverage();
//manipulators
- void Add( double value );
+ void Add(double value);
void Clear();
@@ -42,14 +44,14 @@
double SumOfSquares() const { return m_s2; }
double S2() const { return m_s2; }
- double Average() const { return ( m_n == m_window_size ) ? (m_s1/m_n) : 0; }
-
- double Variance() const { return ( m_n == m_window_size ) ?
- (m_s2 - m_s1*m_s1/m_n) / (m_n-1) : 0; }
+ double Average() const { return ( m_n == m_window_size ) ? (m_s1 / m_n) : 0; }
+ double Variance() const { return ( m_n == m_window_size ) ? (m_s2 - m_s1 * m_s1 / m_n) / (m_n - 1) : 0; }
double StdDeviation() const { return sqrt(Variance()); }
- double StdError() const { return ( m_n == m_window_size ) ?
- sqrt(m_s2 - m_s1*m_s1/m_n / (m_n * (m_n-1))) : 0; }
+ double StdError() const
+ {
+ return ( m_n == m_window_size ) ? sqrt(m_s2 - m_s1 * m_s1 / m_n / (m_n * (m_n - 1))) : 0;
+ }
// Notation Shortcuts
double Ave() const { return Average(); }
Modified: development/source/tools/cSchedule.h
===================================================================
--- development/source/tools/cSchedule.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cSchedule.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -20,10 +20,17 @@
class cMerit;
class cChangeList;
-class cSchedule {
+class cSchedule
+{
protected:
int item_count;
cChangeList* m_change_list;
+
+
+ cSchedule(); // @not_implemented
+ cSchedule(const cSchedule&); // @not_implemented
+ cSchedule& operator=(const cSchedule&); // @not_implemented
+
public:
cSchedule(int _item_count);
virtual ~cSchedule();
Modified: development/source/tools/cString.cc
===================================================================
--- development/source/tools/cString.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cString.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -436,7 +436,7 @@
cString new_st(GetSize());
for( int i=0; i<GetSize(); ++i ){
// new_st[i] = (*this)[GetSize()-i-1]; // @CAO Problem in new gcc
- new_st[i] = GetData()[GetSize()-i-1];
+ new_st[i] = value->GetData()[GetSize()-i-1];
}
(*this) = new_st;
}
@@ -484,7 +484,7 @@
ws = false;
}
// new_st[pos] = (*this)[i]; // copy it & increment pos @CAO prob in gcc
- new_st[pos] = GetData()[i]; // copy it & increment pos
+ new_st[pos] = value->GetData()[i]; // copy it & increment pos
++pos;
}
}
@@ -493,17 +493,18 @@
}
-void cString::RemoveWhitespace(){
+void cString::RemoveWhitespace()
+{
int i;
int new_size = 0;
- for( i=0; i<GetSize(); ++i ){ // count new size
- if( !IsWhitespace(i) ) ++new_size;
+ for (i = 0; i < GetSize(); ++i) { // count new size
+ if (!IsWhitespace(i)) ++new_size;
}
cString new_st(new_size); // allocate new string
int pos = 0;
- for( i=0; i<GetSize(); ++i ){ // count new size
- if( !IsWhitespace(i) ){
- new_st[pos] = GetData()[i]; // copy it & increment pos @CAO prob in GCC
+ for (i = 0; i < GetSize(); ++i) { // count new size
+ if (!IsWhitespace(i)) {
+ new_st[pos] = value->GetData()[i]; // copy it & increment pos @CAO prob in GCC
++pos;
}
}
@@ -511,17 +512,18 @@
}
-void cString::RemoveChar(char out_char){
+void cString::RemoveChar(char out_char)
+{
int i;
int new_size = 0;
- for( i=0; i<GetSize(); ++i ){ // count new size
- if( GetData()[i] != out_char ) ++new_size;
+ for (i = 0; i < GetSize(); ++i) { // count new size
+ if (value->GetData()[i] != out_char) ++new_size;
}
cString new_st(new_size); // allocate new string
int pos = 0;
- for( i=0; i<GetSize(); ++i ){ // count new size
- if( GetData()[i] != out_char ){
- new_st[pos] = GetData()[i]; // copy it & increment pos @CAO prob in GCC
+ for(i = 0; i < GetSize(); ++i) { // count new size
+ if (value->GetData()[i] != out_char ) {
+ new_st[pos] = value->GetData()[i]; // copy it & increment pos @CAO prob in GCC
++pos;
}
}
@@ -535,7 +537,7 @@
int newpos = 0;
for( i=0; i<GetSize(); ++i ){ // count new size
if( i != pos ){
- new_st[newpos++] = GetData()[i]; // copy it & increment pos
+ new_st[newpos++] = value->GetData()[i]; // copy it & increment pos
}
}
(*this) = new_st; // assign the new_st to this
@@ -636,9 +638,9 @@
return in;
}
-ostream& operator << (ostream& out, const cString & string)
+ostream& operator << (ostream& out, const cString& string)
{
- out << string.GetData();
+ out << static_cast<const char*>(string);
return out;
}
Modified: development/source/tools/cString.h
===================================================================
--- development/source/tools/cString.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cString.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -25,67 +25,61 @@
* manipulating and comparing strings.
**/
-class cString {
+class cString
+{
protected:
- void CopyOnWrite(){
- if( value->IsShared() ){ // if it is shared
- value->RemoveRef(); // remove our reference count
- value = new cStringData(*value); // make own copy of value
- }
- }
+ inline void CopyOnWrite();
// -- Contained Classes --
private:
// Declarations (only needed)
class cStringData;
- // {{{ -- cCharProxy -- To detect rvalue vs lvalue ---------------------
-
- class cCharProxy{
+ // cCharProxy -- To detect rvalue vs lvalue ---------------------
+ class cCharProxy
+ {
private:
- cString & string;
+ cString& string;
short index;
public:
- cCharProxy( cString & _string, short _index) :
- string(_string), index(_index) {;}
+ cCharProxy(cString& _string, short _index) : string(_string), index(_index) { ; }
- inline cCharProxy & operator= (char c); // lvalue
- inline cCharProxy & operator+= (char c); // lvalue
- inline cCharProxy & operator-= (char c); // lvalue
- inline cCharProxy & operator++ (); // lvalue (prefix)
- inline char operator++ (int dummy); // lvalue (postfix)
- inline cCharProxy & operator-- (); // lvalue (prefix)
- inline char operator-- (int dummy); // lvalue (postfix)
- inline operator char () const ; // rvalue
+ inline cCharProxy& operator=(char c); // lvalue
+ inline cCharProxy& operator+=(char c); // lvalue
+ inline cCharProxy& operator-=(char c); // lvalue
+ inline cCharProxy& operator++(); // lvalue (prefix)
+ inline char operator++(int dummy); // lvalue (postfix)
+ inline cCharProxy& operator--(); // lvalue (prefix)
+ inline char operator--(int dummy); // lvalue (postfix)
+ inline operator char () const; // rvalue
};
-
- //friend cCharProxy; // Telling rvalue vs lvalue ....
- // porting to gcc 3.1 -- k
friend class cCharProxy; // Telling rvalue vs lvalue ....
- // }}} End cCharProxy
- // {{{ -- cStringData -- Holds the actual data and is reference count --
- class cStringData{
+ // cStringData -- Holds the actual data and is reference count --
+ class cStringData
+ {
// NOTE: Terminating NULL is always there (you can't assign!!)
-
private:
short refs; // Number of references
short size; // size of data (NOT INCLUDING TRAILING NULL)
- char * data;
+ char* data;
+
+
+ cStringData(); // @not_implemented
public:
explicit cStringData(short in_size);
- cStringData(short in_size, const char * in);
- cStringData(const cStringData & in);
+ cStringData(short in_size, const char* in);
+ cStringData(const cStringData& in);
~cStringData(){
assert(refs == 0); // Deleting cStringData with References!!
delete [] data;
}
-
- cStringData & operator= (const cStringData & in) {
+ cStringData& operator=(const cStringData& in)
+ {
delete [] data;
size = in.GetSize();
data = new char [size+1];
@@ -95,75 +89,64 @@
return (*this);
}
-
short GetSize() const { return size; }
+ const char* GetData() const { return data; }
- const char * GetData() const { return data; }
-
- char operator[] (int index) const {
+ char operator[] (int index) const
+ {
assert(index >= 0); // Lower Bounds Error
assert(index <= size); // Upper Bounds Error
return data[index];
}
- char & operator[](int index) {
+ char& operator[](int index)
+ {
assert(index >= 0); // Lower Bounds Error
assert(index <= size); // Upper Bounds Error
assert(index != size); // Cannot Change Terminating NULL
return data[index];
}
-
bool IsShared() { return (refs > 1); }
bool AtMaxRefs() { return (refs >= MAX_STRING_REF_COUNT); }
- short RemoveRef() {
+ short RemoveRef()
+ {
assert( refs > 0 ); // Reference count corrupted
- return(--refs);
+ return (--refs);
}
- cStringData * NewRef() { ++refs; return this; }
-
+ cStringData* NewRef() { ++refs; return this; }
};
- // }}} End cStringData
- // -- Constants --
public:
static const int MAX_LENGTH;
-
-
- // -- INTERFACE -----------------------------------------------------------
-public:
-
- // -- Constructors --
- cString(const char * in = "") : value(new cStringData(strlen(in), in)) {
+ cString(const char* in = "") : value(new cStringData(strlen(in), in))
+ {
assert( in != NULL ); // NULL input string
assert( value != NULL ); // Memory Allocation Error: Out of Memory
}
- explicit cString(const int size) : value(new cStringData(size)) {
- assert( value!=NULL ); // Memory Allocation Error: Out of Memory
+ explicit cString(const int size) : value(new cStringData(size))
+ {
+ assert( value != NULL ); // Memory Allocation Error: Out of Memory
}
- cString(const cString & in) { CopyString(in); }
+ cString(const cString& in) { CopyString(in); }
+ virtual ~cString() { if (value->RemoveRef() == 0) delete value; }
- // -- Destructor --
- virtual ~cString() { if( value->RemoveRef() == 0 ) delete value; }
-
-
// Cast to const char *
- operator const char * () const { return value->GetData(); }
- const char * operator() () const { return value->GetData(); } // Depricated
- const char * GetData() const { return value->GetData(); } // Depricated
+ operator const char* () const { return value->GetData(); }
-
// Assignment Operators
- cString & operator= (const cString & in){
+ cString& operator=(const cString & in)
+ {
if( value->RemoveRef() == 0 ) delete value;
CopyString(in);
return *this;
}
- cString & operator= (const char * in){
+ cString& operator=(const char* in)
+ {
assert( in != NULL ); // NULL input string
if( value->RemoveRef() == 0 ) delete value;
value = new cStringData(strlen(in),in);
@@ -573,6 +556,14 @@
// -- INLINE INCLUDES --
+void cString::CopyOnWrite()
+{
+ if (value->IsShared()) { // if it is shared
+ value->RemoveRef(); // remove our reference count
+ value = new cStringData(*value); // make own copy of value
+ }
+}
+
cString::cCharProxy & cString::cCharProxy::operator= (char c){ // lvalue
string.CopyOnWrite();
(*(string.value))[index] = c;
Modified: development/source/tools/cStringIterator.h
===================================================================
--- development/source/tools/cStringIterator.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cStringIterator.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -21,12 +21,19 @@
class cStringList;
-class cStringIterator {
+class cStringIterator
+{
private:
tConstListIterator<cString> list_it;
static const cString null_str;
+
+
+ cStringIterator(); // @not_implemented
+ cStringIterator(const cStringIterator&); // @not_implemented
+ cStringIterator& operator=(const cStringIterator&); // @not_implemented
+
public:
- cStringIterator(const cStringList & in_list);
+ cStringIterator(const cStringList& in_list);
void Reset() { list_it.Reset(); }
const cString & Get() {
Modified: development/source/tools/cStringList.h
===================================================================
--- development/source/tools/cStringList.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cStringList.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -19,22 +19,25 @@
#endif
-class cStringList {
+class cStringList
+{
private:
tList<cString> string_list;
- inline cString ReturnString(cString * out_string) {
+ inline cString ReturnString(cString * out_string)
+ {
cString tmp_string(*out_string);
delete out_string;
return tmp_string;
}
+
public:
cStringList() { ; }
- cStringList(const cString & _list, char seperator=' ');
- cStringList(const cStringList & _list);
+ cStringList(const cString& _list, char seperator = ' ');
+ cStringList(const cStringList& _list);
~cStringList();
- cStringList & operator=(const cStringList & _list);
+ cStringList& operator=(const cStringList & _list);
int GetSize() const { return string_list.GetSize(); }
cString GetLine(int line_num) const { return *(string_list.GetPos(line_num)); }
Modified: development/source/tools/cStringUtil.h
===================================================================
--- development/source/tools/cStringUtil.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cStringUtil.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -15,7 +15,12 @@
#include "cString.h"
#endif
-struct cStringUtil {
+class cStringUtil
+{
+private:
+ cStringUtil(); // @not_implemented
+
+public:
static cString Stringf(const char * fmt, ...);
static cString ToRomanNumeral(const int in_value);
static int StrLength(const char * _in);
@@ -29,8 +34,7 @@
* @param offset This parameter determines how many characters the second
* string should be shifted wrt. the first before the comparison.
**/
- static int Distance(const cString & string1, const cString & string2,
- int offset=0);
+ static int Distance(const cString& string1, const cString& string2, int offset = 0);
/**
* Calculate the edit distance between two strings.
@@ -40,20 +44,18 @@
* @param string2 the second string to compare.
* @param description The string to write out the differences
**/
- static int EditDistance(const cString & string1, const cString & string2);
- static int EditDistance(const cString & string1, const cString & string2,
- cString & info, const char gap=' ');
+ static int EditDistance(const cString& string1, const cString& string2);
+ static int EditDistance(const cString& string1, const cString& string2, cString& info, const char gap = ' ');
/**
* Various, overloaded conversion functions for use in templates. Note
* that in all cases, the second argument is simply to set the return type.
**/
- static const cString & Convert(const cString & in_string,
- const cString & out_string);
- static bool Convert(const cString & in_string, bool type_bool);
- static int Convert(const cString & in_string, int type_int);
- static double Convert(const cString & in_string, double type_double);
- static cString Convert(const cString & in_string);
+ static const cString & Convert(const cString& in_string, const cString& out_string);
+ static bool Convert(const cString& in_string, bool type_bool);
+ static int Convert(const cString& in_string, int type_int);
+ static double Convert(const cString& in_string, double type_double);
+ static cString Convert(const cString& in_string);
static cString Convert(bool in_bool);
static cString Convert(int in_int);
static cString Convert(double in_double);
Modified: development/source/tools/cTools.cc
===================================================================
--- development/source/tools/cTools.cc 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cTools.cc 2006-01-20 13:46:47 UTC (rev 442)
@@ -30,11 +30,11 @@
{
if (verbose) cout << "Checking for directory '" << dirname << "'..." << flush;
- FILE * fp = fopen ( dirname(), "r" );
+ FILE * fp = fopen(dirname, "r");
if (fp == 0) {
if (errno == ENOENT) {
if (verbose) cout << " not found, creating..." << flush;
- if (mkdir( dirname(), (S_IRWXU|S_IRWXG|S_IRWXO) )) {
+ if (mkdir(dirname, (S_IRWXU|S_IRWXG|S_IRWXO))) {
if (verbose)
cerr << endl << "Warning: Failed to create directory '" << dirname << "'." << endl;
return false;
Modified: development/source/tools/cTools.h
===================================================================
--- development/source/tools/cTools.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cTools.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -17,7 +17,11 @@
class cString;
-class cTools {
+class cTools
+{
+private:
+ cTools(); // @not_implemented
+
public:
static bool MkDir(const cString& dirname, bool verbose=false);
};
Modified: development/source/tools/cUInt.h
===================================================================
--- development/source/tools/cUInt.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cUInt.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -17,15 +17,17 @@
#define LONG_C_UINT
#ifdef LONG_C_UINT
-class cUInt {
+class cUInt
+{
private:
long value;
int size;
+
public:
inline cUInt() { size = 0; value = 0; }
inline cUInt(int in_size) { size = in_size, value = 0; }
inline cUInt(int in_size, int in_value) { size = in_size, value = in_value; }
- inline ~cUInt() {;}
+ inline ~cUInt() { ; }
inline void Print() const { printf ("%ld", value); }
inline int AsInt() const { return (int) value; }
Modified: development/source/tools/cWeightedIndex.h
===================================================================
--- development/source/tools/cWeightedIndex.h 2006-01-18 19:32:53 UTC (rev 441)
+++ development/source/tools/cWeightedIndex.h 2006-01-20 13:46:47 UTC (rev 442)
@@ -24,13 +24,18 @@
* that weight.
**/
-class cWeightedIndex {
+class cWeightedIndex
+{
protected:
int size;
tArray<double> item_weight;
tArray<double> subtree_weight;
+
void AdjustSubtree(int id, double weight_change);
+
+ cWeightedIndex(); // @not_implemented
+
public:
cWeightedIndex(int in_size);
~cWeightedIndex();
More information about the Avida-cvs
mailing list