[Avida-SVN] r2860 - in development: . Avida.xcodeproj source/analyze source/tools
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Tue Oct 21 11:26:41 PDT 2008
Author: brysonda
Date: 2008-10-21 14:26:41 -0400 (Tue, 21 Oct 2008)
New Revision: 2860
Removed:
development/source/tools/cDataEntry.cc
development/source/tools/cDataEntry.h
development/source/tools/tArgDataEntry.h
development/source/tools/tDataEntryBase.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/CMakeLists.txt
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyze.h
development/source/tools/tDataEntry.h
development/source/tools/tDataEntryCommand.h
development/source/tools/tDataManager.h
Log:
Restructure tDataEntry and tDataManager hierarchy for simplicity and thread/context safety. tDataEntry objects no longer hold a pointer to the target, rather they simply hold the function pointers needed to access the data entry.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/Avida.xcodeproj/project.pbxproj 2008-10-21 18:26:41 UTC (rev 2860)
@@ -386,7 +386,6 @@
7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPUInterface.cc; sourceTree = "<group>"; };
7005A70909BA0FBE0007E16E /* cOrgInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cOrgInterface.h; sourceTree = "<group>"; };
700AE91B09DB65F200A073FD /* cTaskContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTaskContext.h; sourceTree = "<group>"; };
- 700E11BC0A0815B600B604CD /* cDataEntry.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDataEntry.cc; sourceTree = "<group>"; };
700E28CF0859FFD700CF158A /* tObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tObjectFactory.h; sourceTree = "<group>"; };
700E2B83085DE50C00CF158A /* avida-viewer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-viewer"; sourceTree = BUILT_PRODUCTS_DIR; };
7013845F09028B3E0087ED2E /* cAvidaConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAvidaConfig.h; sourceTree = "<group>"; };
@@ -658,7 +657,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>"; };
- 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>"; };
70B0884B08F5FE4500FC65FE /* cDataManager_Base.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDataManager_Base.h; sourceTree = "<group>"; };
@@ -723,11 +721,9 @@
70B08B8008FB2E5500FC65FE /* cTools.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTools.h; sourceTree = "<group>"; };
70B08B8108FB2E5500FC65FE /* cUInt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cUInt.h; sourceTree = "<group>"; };
70B08B8208FB2E5500FC65FE /* cWeightedIndex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cWeightedIndex.h; sourceTree = "<group>"; };
- 70B08B8308FB2E5500FC65FE /* tArgDataEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tArgDataEntry.h; sourceTree = "<group>"; };
70B08B8408FB2E5500FC65FE /* tArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tArray.h; sourceTree = "<group>"; };
70B08B8508FB2E5500FC65FE /* tBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tBuffer.h; sourceTree = "<group>"; };
70B08B8608FB2E5500FC65FE /* tDataEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntry.h; sourceTree = "<group>"; };
- 70B08B8708FB2E5500FC65FE /* tDataEntryBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntryBase.h; sourceTree = "<group>"; };
70B08B8808FB2E5500FC65FE /* tDataEntryCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntryCommand.h; sourceTree = "<group>"; };
70B08B8908FB2E5500FC65FE /* tDataManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataManager.h; sourceTree = "<group>"; };
70B08B8A08FB2E5500FC65FE /* tDictionary.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDictionary.h; sourceTree = "<group>"; };
@@ -1528,17 +1524,14 @@
704368F50C32E6AB00A05ABA /* cFlexVar.h */,
7057886F0A21FE8D00E85D8E /* cFixedBlock.cc */,
705788700A21FE8D00E85D8E /* cFixedCoords.cc */,
- 700E11BC0A0815B600B604CD /* cDataEntry.cc */,
70B08B9008FB2E6B00FC65FE /* cTools.cc */,
70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */,
70B08B8008FB2E5500FC65FE /* cTools.h */,
70B08B8108FB2E5500FC65FE /* cUInt.h */,
70B08B8208FB2E5500FC65FE /* cWeightedIndex.h */,
- 70B08B8308FB2E5500FC65FE /* tArgDataEntry.h */,
70B08B8408FB2E5500FC65FE /* tArray.h */,
70B08B8508FB2E5500FC65FE /* tBuffer.h */,
70B08B8608FB2E5500FC65FE /* tDataEntry.h */,
- 70B08B8708FB2E5500FC65FE /* tDataEntryBase.h */,
70B08B8808FB2E5500FC65FE /* tDataEntryCommand.h */,
70B08B8908FB2E5500FC65FE /* tDataManager.h */,
70B08B8A08FB2E5500FC65FE /* tDictionary.h */,
@@ -1604,7 +1597,6 @@
70B0885108F5FE5800FC65FE /* cDataManager_Base.cc */,
70B0885208F5FE5800FC65FE /* cDefaultMessageDisplay.cc */,
70B0885308F5FE5800FC65FE /* cDoubleSum.cc */,
- 70B0884808F5FE4500FC65FE /* cDataEntry.h */,
70B0884908F5FE4500FC65FE /* cDataFile.h */,
70B0884A08F5FE4500FC65FE /* cDataFileManager.h */,
70B0884B08F5FE4500FC65FE /* cDataManager_Base.h */,
Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/CMakeLists.txt 2008-10-21 18:26:41 UTC (rev 2860)
@@ -275,7 +275,6 @@
${TOOLS_DIR}/cChangeList.cc
${TOOLS_DIR}/cConstBurstSchedule.cc
${TOOLS_DIR}/cConstSchedule.cc
- ${TOOLS_DIR}/cDataEntry.cc
${TOOLS_DIR}/cDataFile.cc
${TOOLS_DIR}/cDataFileManager.cc
${TOOLS_DIR}/cDataManager_Base.cc
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/analyze/cAnalyze.cc 2008-10-21 18:26:41 UTC (rev 2860)
@@ -64,7 +64,6 @@
#include "cSchedule.h"
#include "cSpecies.h"
#include "cStringIterator.h"
-#include "tArgDataEntry.h"
#include "tDataEntry.h"
#include "tDataEntryCommand.h"
#include "tMatrix.h"
@@ -982,9 +981,8 @@
output_it.Reset();
tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(genotype);
// genotype->SetSpecialArgs(data_command->GetArgs());
- data_command->SetValue(cur_line.PopWord());
+ data_command->SetValue(genotype, cur_line.PopWord());
}
// Give this genotype a name. Base it on the ID if possible.
@@ -2119,7 +2117,6 @@
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
while ((data_command = output_it.Next()) != NULL) {
cur_genotype->SetSpecialArgs(data_command->GetArgs());
- data_command->SetTarget(cur_genotype);
cFlexVar cur_value = data_command->GetValue(cur_genotype);
if (format_type == FILE_TYPE_HTML) {
int compare = 0;
@@ -2132,7 +2129,7 @@
HTMLPrintStat(cur_value, fp, compare, data_command->GetHtmlCellFlags(), data_command->GetNull());
}
else { // if (format_type == FILE_TYPE_TEXT) {
- fp << data_command->GetValue() << " ";
+ fp << data_command->GetValue(cur_genotype) << " ";
}
}
if (format_type == FILE_TYPE_HTML) fp << "</tr>";
@@ -2179,10 +2176,9 @@
output_it.Reset();
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(cur_genotype);
cur_genotype->SetSpecialArgs(data_command->GetArgs());
for (int j = 0; j < cur_genotype->GetNumCPUs(); j++) {
- output_counts[count].Add( data_command->GetValue().AsDouble() );
+ output_counts[count].Add( data_command->GetValue(cur_genotype).AsDouble() );
}
count++;
}
@@ -2240,7 +2236,7 @@
// Scan the functions list for the keyword we need...
SetupGenotypeDataList();
- tListIterator< tDataEntryBase<cAnalyzeGenotype> >
+ tListIterator< tDataEntry<cAnalyzeGenotype> >
output_it(genotype_data_list);
// Divide up the keyword into its acrual entry and its arguments...
@@ -2314,13 +2310,12 @@
output_it.Reset();
if (file_type == FILE_TYPE_HTML) fp << "<td>";
- cur_command->SetTarget(genotype);
genotype->SetSpecialArgs(cur_command->GetArgs());
if (file_type == FILE_TYPE_HTML) {
- HTMLPrintStat(cur_command->GetValue(), fp, 0, cur_command->GetHtmlCellFlags(), cur_command->GetNull());
+ HTMLPrintStat(cur_command->GetValue(genotype), fp, 0, cur_command->GetHtmlCellFlags(), cur_command->GetNull());
}
else { // if (file_type == FILE_TYPE_TEXT) {
- fp << cur_command->GetValue() << " ";
+ fp << cur_command->GetValue(genotype) << " ";
}
}
if (file_type == FILE_TYPE_HTML) fp << "</tr>";
@@ -2360,15 +2355,15 @@
}
// Construct a linked list of details needed...
- tList< tDataEntryBase<cAnalyzeGenotype> > output_list;
- tListIterator< tDataEntryBase<cAnalyzeGenotype> > output_it(output_list);
+ tList< tDataEntry<cAnalyzeGenotype> > output_list;
+ tListIterator< tDataEntry<cAnalyzeGenotype> > output_it(output_list);
// For the moment, just put everything into the output list.
SetupGenotypeDataList();
// If no args were given, load all of the stats.
if (cur_string.CountNumWords() == 0) {
- tListIterator< tDataEntryBase<cAnalyzeGenotype> >
+ tListIterator< tDataEntry<cAnalyzeGenotype> >
genotype_data_it(genotype_data_list);
while (genotype_data_it.Next() != NULL) {
output_list.PushRear(genotype_data_it.Get());
@@ -2382,7 +2377,7 @@
bool found_entry = false;
// Scan the genotype data list for the current entry
- tListIterator< tDataEntryBase<cAnalyzeGenotype> >
+ tListIterator< tDataEntry<cAnalyzeGenotype> >
genotype_data_it(genotype_data_list);
while (genotype_data_it.Next() != NULL) {
@@ -2470,7 +2465,7 @@
cAnalyzeGenotype * genotype = batch[batch_id].List().GetFirst();
if (genotype == NULL) continue;
output_it.Reset();
- tDataEntryBase<cAnalyzeGenotype> * data_entry = NULL;
+ tDataEntry<cAnalyzeGenotype> * data_entry = NULL;
const cString & batch_name = batch[batch_id].Name();
if (file_type == FILE_TYPE_HTML) {
fp << "<tr><th><a href=lineage." << batch_name << ".html>"
@@ -2480,7 +2475,6 @@
}
while ((data_entry = output_it.Next()) != NULL) {
- data_entry->SetTarget(genotype);
if (file_type == FILE_TYPE_HTML) {
fp << "<td align=center><a href=\""
<< data_entry->GetName() << "." << batch_name << ".png\">"
@@ -2602,8 +2596,7 @@
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
cAnalyzeGenotype * cur_genotype;
while ((cur_genotype = batch_it.Next()) != NULL) {
- data_command->SetTarget(cur_genotype);
- const cString cur_name(data_command->GetValue().AsString());
+ const cString cur_name(data_command->GetValue(cur_genotype).AsString());
int count = 0;
count_dict.Find(cur_name, count);
count += cur_genotype->GetNumCPUs();
@@ -4858,8 +4851,7 @@
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(genotype);
- fp << data_command->GetValue() << " ";
+ fp << data_command->GetValue(genotype) << " ";
}
fp << endl;
@@ -4914,9 +4906,8 @@
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
cAnalyzeGenotype null_genotype(m_world, "a", inst_set);
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(genotype);
genotype->SetSpecialArgs(data_command->GetArgs());
- const cFlexVar cur_value = data_command->GetValue();
+ const cFlexVar cur_value = data_command->GetValue(genotype);
const cFlexVar null_value = data_command->GetValue(&null_genotype);
int compare = CompareFlexStat(cur_value, null_value, data_command->GetCompareType());
if (compare > 0) {
@@ -4974,9 +4965,8 @@
tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
int cur_col = 0;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(&test_genotype);
test_genotype.SetSpecialArgs(data_command->GetArgs());
- const cFlexVar test_value = data_command->GetValue();
+ const cFlexVar test_value = data_command->GetValue(&test_genotype);
int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), data_command->GetCompareType());
if (file_type == FILE_TYPE_HTML) {
@@ -5206,9 +5196,8 @@
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
int cur_col = 0;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(&test_genotype);
test_genotype.SetSpecialArgs(data_command->GetArgs());
- const cFlexVar test_value = data_command->GetValue();
+ const cFlexVar test_value = data_command->GetValue(&test_genotype);
// This is done so that under 'binary' option it marks
// the task as being influenced by the mutation iff
@@ -5431,9 +5420,8 @@
tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
int cur_trait = 0;
while ((data_command = output_it.Next()) != NULL) {
- data_command->SetTarget(&test_genotype);
test_genotype.SetSpecialArgs(data_command->GetArgs());
- const cFlexVar test_value = data_command->GetValue();
+ const cFlexVar test_value = data_command->GetValue(&test_genotype);
int compare_type = data_command->GetCompareType();
int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), compare_type);
@@ -9228,13 +9216,13 @@
#define ADD_GDATA(TYPE, KEYWORD, DESC, GET, SET, COMP, NSTR, HSTR) \
{ \
cString nstr_str(#NSTR), hstr_str(#HSTR); \
- cString null_str = "0"; \
- if (nstr_str != "0") null_str = NSTR; \
- cString html_str = "align=center"; \
- if (hstr_str != "0") html_str = HSTR; \
- \
- genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, TYPE> \
- (KEYWORD, DESC, &cAnalyzeGenotype::GET, &cAnalyzeGenotype::SET, COMP, null_str, html_str)); \
+ cString null_str = "0"; \
+ if (nstr_str != "0") null_str = NSTR; \
+ cString html_str = "align=center"; \
+ if (hstr_str != "0") html_str = HSTR; \
+ \
+ genotype_data_list.PushRear(new tDataEntryOfType<cAnalyzeGenotype, TYPE> \
+ (KEYWORD, DESC, &cAnalyzeGenotype::GET, &cAnalyzeGenotype::SET, COMP, null_str, html_str)); \
}
@@ -9327,16 +9315,16 @@
cString t_name, t_desc;
t_name.Set("task.%d", i);
t_desc = environment.GetTask(i).GetDesc();
- genotype_data_list.PushRear(new tArgDataEntry<cAnalyzeGenotype, int, int>
- (t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i, 5));
+ genotype_data_list.PushRear(
+ new tDataEntryWithArg<cAnalyzeGenotype, int, int>(t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i, 5));
}
for (int i = 0; i < environment.GetInputSize(); i++){
cString t_name, t_desc;
t_name.Set("env_input.%d", i);
t_desc.Set("env_input.%d", i);
- genotype_data_list.PushRear(new tArgDataEntry<cAnalyzeGenotype, int, int>
- (t_name, t_desc, &cAnalyzeGenotype::GetEnvInput, i, 0));
+ genotype_data_list.PushRear(
+ new tDataEntryWithArg<cAnalyzeGenotype, int, int>(t_name, t_desc, &cAnalyzeGenotype::GetEnvInput, i, 0));
}
// The remaining values should actually go in a seperate list called
@@ -9362,7 +9350,7 @@
cString stat_name = arg_list.Pop(':');
// Create an iterator to scan the genotype data list for the current entry.
- tListIterator< tDataEntryBase<cAnalyzeGenotype> > genotype_data_it(genotype_data_list);
+ tListIterator< tDataEntry<cAnalyzeGenotype> > genotype_data_it(genotype_data_list);
while (genotype_data_it.Next() != (void *) NULL) {
if (genotype_data_it.Get()->GetName() == stat_name) {
@@ -9385,7 +9373,7 @@
// If no args were given, load all of the stats.
if (arg_list.GetSize() == 0) {
- tListIterator< tDataEntryBase<cAnalyzeGenotype> >
+ tListIterator< tDataEntry<cAnalyzeGenotype> >
genotype_data_it(genotype_data_list);
while (genotype_data_it.Next() != (void *) NULL) {
tDataEntryCommand<cAnalyzeGenotype> * entry_command =
@@ -9402,7 +9390,7 @@
bool found_entry = false;
// Scan the genotype data list for the current entry
- tListIterator< tDataEntryBase<cAnalyzeGenotype> >
+ tListIterator< tDataEntry<cAnalyzeGenotype> >
genotype_data_it(genotype_data_list);
while (genotype_data_it.Next() != (void *) NULL) {
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/analyze/cAnalyze.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -70,7 +70,7 @@
class cAnalyzeFunction;
class cAnalyzeCommandDefBase;
class cAnalyzeScreen;
-template <class T> class tDataEntryBase;
+template <class T> class tDataEntry;
class cInstSet;
class cAnalyzeGenotype;
class cInitFile;
@@ -123,7 +123,7 @@
int interactive_depth; // How nested are we if in interactive mode?
- tList< tDataEntryBase<cAnalyzeGenotype> > genotype_data_list;
+ tList< tDataEntry<cAnalyzeGenotype> > genotype_data_list;
cRandom random;
Deleted: development/source/tools/cDataEntry.cc
===================================================================
--- development/source/tools/cDataEntry.cc 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/cDataEntry.cc 2008-10-21 18:26:41 UTC (rev 2860)
@@ -1,26 +0,0 @@
-/*
- * cDataEntry.cc
- * Avida
- *
- * Copyright 1999-2008 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cDataEntry.h"
-
Deleted: development/source/tools/cDataEntry.h
===================================================================
--- development/source/tools/cDataEntry.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/cDataEntry.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -1,76 +0,0 @@
-/*
- * cDataEntry.h
- * Avida
- *
- * Called "data_entry.hh" prior to 12/2/05.
- * Copyright 1999-2008 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cDataEntry_h
-#define cDataEntry_h
-
-#ifndef cString_h
-#include "cString.h"
-#endif
-#if USE_tMemTrack
-# ifndef tMemTrack_h
-# include "tMemTrack.h"
-# endif
-#endif
-
-
-#include <iostream>
-
-class cDataEntry {
-#if USE_tMemTrack
- tMemTrack<cDataEntry> mt;
-#endif
-private:
- cString name; // Short Name
- cString desc; // Descriptive Name
- int compare_type; // ID to indicate how values should be compared.
- cString null_value; // Value when "off", such as "0", "Inf.", or "N/A"
- cString html_table_flags; // String to include in <td> entry in html mode.
-public:
- cDataEntry(const cString & _name, const cString & _desc,
- int _compare_type = 0,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : name(_name), desc(_desc), compare_type(_compare_type), null_value(_null), html_table_flags(_html_cell) { ; }
- virtual ~cDataEntry() { ; }
-
- const cString & GetName() const { return name; }
- const cString & GetDesc() const { return desc; }
- int GetCompareType() const { return compare_type; }
- const cString & GetNull() const { return null_value; }
- const cString & GetHtmlCellFlags() const { return html_table_flags; }
-
- template<class Archive>
- void serialize(Archive & a, const unsigned int version)
- {
- a.ArkvObj("name", name);
- a.ArkvObj("desc", desc);
- a.ArkvObj("null_value", null_value);
- a.ArkvObj("html_table_flags", html_table_flags);
- }
-
-};
-
-#endif
Deleted: development/source/tools/tArgDataEntry.h
===================================================================
--- development/source/tools/tArgDataEntry.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/tArgDataEntry.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -1,61 +0,0 @@
-/*
- * tArgDataEntry.h
- * Avida
- *
- * Called "tArgDataEntry.hh" prior to 12/7/05.
- * Copyright 1999-2008 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef tArgDataEntry_h
-#define tArgDataEntry_h
-
-#include <iostream>
-
-#ifndef tDataEntryBase_h
-#include "tDataEntryBase.h"
-#endif
-
-class cString;
-
-template <class T, class OUT, class ARG> class tArgDataEntry
- : public tDataEntryBase<T> {
-protected:
- OUT (T::*DataRetrieval)(ARG) const;
- ARG arg;
-public:
- tArgDataEntry(const cString & _name, const cString & _desc,
- OUT (T::*_funR)(ARG) const, ARG _arg,
- int _compare_type=0,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : tDataEntryBase<T>(_name, _desc, _compare_type, _null, _html_cell),
- DataRetrieval(_funR), arg(_arg) { ; }
-
- cFlexVar Get() const {
- assert(this->target != NULL);
- return cFlexVar( (this->target->*DataRetrieval)(arg) );
- }
- cFlexVar Get(const T * tmp_target) const {
- assert(tmp_target != NULL);
- return cFlexVar( (tmp_target->*DataRetrieval)(arg) );
- }
-};
-
-#endif
Modified: development/source/tools/tDataEntry.h
===================================================================
--- development/source/tools/tDataEntry.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/tDataEntry.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -40,52 +40,78 @@
#include "cStringUtil.h"
#endif
-#ifndef tDataEntryBase_h
-#include "tDataEntryBase.h"
-#endif
+template <class TargetType> class tDataEntry
+{
+private:
+ cString m_name; // Short Name
+ cString m_desc; // Descriptive Name
+ int m_compare_type; // ID to indicate how values should be compared.
+ cString m_null_value; // Value when "off", such as "0", "Inf.", or "N/A"
+ cString m_html_table_flags; // String to include in <td> entry in html mode.
+
+public:
+ tDataEntry(const cString& name, const cString& desc, int compare_type = 0,
+ const cString& null = "0", const cString& html_cell = "align=center")
+ : m_name(name), m_desc(desc), m_compare_type(compare_type), m_null_value(null), m_html_table_flags(html_cell) { ; }
+ virtual ~tDataEntry() { ; }
+
+ const cString& GetName() const { return m_name; }
+ const cString& GetDesc() const { return m_desc; }
+ int GetCompareType() const { return m_compare_type; }
+ const cString& GetNull() const { return m_null_value; }
+ const cString& GetHtmlCellFlags() const { return m_html_table_flags; }
+
+ virtual bool Set(TargetType* target, const cString& value) const { (void) value; return false; }
+ virtual cFlexVar Get(const TargetType* target) const = 0;
+};
-#if USE_tMemTrack
-# ifndef tMemTrack_h
-# include "tMemTrack.h"
-# endif
-#endif
-template <class T, class OUT> class tDataEntry : public tDataEntryBase<T> {
-#if USE_tMemTrack
- tMemTrack<tDataEntry<T, OUT> > mt;
-#endif
+template <class TargetType, class EntryType> class tDataEntryOfType : public tDataEntry<TargetType>
+{
protected:
- OUT (T::*DataGet)() const;
- void (T::*DataSet)(OUT);
- int (T::*DataCompare)(T*) const;
+ EntryType (TargetType::*DataGet)() const;
+ void (TargetType::*DataSet)(EntryType);
-// int CmpNULL(T *) const { return 0; }
public:
- tDataEntry(const cString & _name, const cString & _desc,
- OUT (T::*_funR)() const,
- void (T::*_funS)(OUT _val) = NULL,
- int _compare_type=0,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : tDataEntryBase<T>(_name, _desc, _compare_type, _null, _html_cell), DataGet(_funR),
- DataSet(_funS) {;}
+ tDataEntryOfType(const cString& name, const cString& desc,
+ EntryType (TargetType::*_funR)() const, void (TargetType::*_funS)(EntryType _val) = NULL,
+ int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+ : tDataEntry<TargetType>(name, desc, compare_type, null, html_cell), DataGet(_funR), DataSet(_funS) { ; }
- bool Set(const cString & value) {
- OUT new_value(0);
+ bool Set(TargetType* target, const cString& value) const
+ {
+ assert(target != NULL);
+ EntryType new_value(0);
if (DataSet == 0) return false;
- (this->target->*DataSet)( cStringUtil::Convert(value, new_value) );
+ (target->*DataSet)(cStringUtil::Convert(value, new_value));
return true;
}
- cFlexVar Get() const {
- assert(this->target != NULL);
- return cFlexVar( (this->target->*DataGet)() );
+ cFlexVar Get(const TargetType* target) const
+ {
+ assert(target != NULL);
+ return cFlexVar((target->*DataGet)());
}
+};
- cFlexVar Get(const T * tmp_target) const {
- assert(tmp_target != NULL);
- return cFlexVar( (tmp_target->*DataGet)() );
+
+template <class TargetType, class EntryType, class ArgType> class tDataEntryWithArg : public tDataEntry<TargetType>
+{
+protected:
+ EntryType (TargetType::*DataRetrieval)(ArgType) const;
+ ArgType m_arg;
+
+public:
+ tDataEntryWithArg(const cString& name, const cString& desc, EntryType (TargetType::*_funR)(ArgType) const, ArgType arg,
+ int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+ : tDataEntry<TargetType>(name, desc, compare_type, null, html_cell), DataRetrieval(_funR), m_arg(arg) { ; }
+
+ cFlexVar Get(const TargetType* target) const
+ {
+ assert(target != NULL);
+ return cFlexVar((target->*DataRetrieval)(m_arg));
}
};
+
#endif
Deleted: development/source/tools/tDataEntryBase.h
===================================================================
--- development/source/tools/tDataEntryBase.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/tDataEntryBase.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -1,66 +0,0 @@
-/*
- * tDataEntryBase.h
- * Avida
- *
- * Called "tDataEntryBase.hh" prior to 12/7/05.
- * Copyright 1999-2008 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef tDataEntryBase_h
-#define tDataEntryBase_h
-
-#include <iostream>
-#include <sstream>
-
-#ifndef cDataEntry_h
-#include "cDataEntry.h"
-#endif
-
-#ifndef cFlexVar_h
-#include "cFlexVar.h"
-#endif
-
-#if USE_tMemTrack
-# ifndef tMemTrack_h
-# include "tMemTrack.h"
-# endif
-#endif
-
-class cString;
-
-template <class T> class tDataEntryBase : public cDataEntry {
-#if USE_tMemTrack
- tMemTrack<tDataEntryBase<T> > mt;
-#endif
-protected:
- T * target;
-public:
- tDataEntryBase(const cString & _name, const cString & _desc, int _compare_type,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : cDataEntry(_name, _desc, _compare_type, _null, _html_cell), target(NULL) { ; }
-
- void SetTarget(T * _target) { target = _target; }
- virtual bool Set(const cString & value) { (void) value; return false; }
- virtual cFlexVar Get() const = 0;
- virtual cFlexVar Get(const T * tmp_target) const = 0;
-};
-
-#endif
Modified: development/source/tools/tDataEntryCommand.h
===================================================================
--- development/source/tools/tDataEntryCommand.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/tDataEntryCommand.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -36,34 +36,32 @@
#include "cStringList.h"
#endif
-#ifndef tDataEntryBase_h
-#include "tDataEntryBase.h"
+#ifndef tDataEntry_h
+#include "tDataEntry.h"
#endif
class cString;
-template <class T> class tDataEntryCommand {
+template <class T> class tDataEntryCommand
+{
private:
- tDataEntryBase<T> * data_entry;
- cStringList args;
+ tDataEntry<T>* m_data_entry;
+ cStringList m_args;
public:
- tDataEntryCommand(tDataEntryBase<T> * _entry, const cString & _args="")
- : data_entry(_entry), args(_args, ':') { ; }
+ tDataEntryCommand(tDataEntry<T>* entry, const cString& args = "") : m_data_entry(entry), m_args(args, ':') { ; }
- const cStringList & GetArgs() const { return args; }
- bool HasArg(const cString & test_arg) { return args.HasString(test_arg); }
+ const cStringList& GetArgs() const { return m_args; }
+ bool HasArg(const cString& test_arg) const { return m_args.HasString(test_arg); }
- const cString & GetName() const { return data_entry->GetName(); }
- const cString & GetDesc() const { return data_entry->GetDesc(); }
- int GetCompareType() const { return data_entry->GetCompareType(); }
- const cString & GetNull() const { return data_entry->GetNull(); }
- const cString & GetHtmlCellFlags() const { return data_entry->GetHtmlCellFlags(); }
- cFlexVar GetValue() const { assert(data_entry != NULL); return data_entry->Get(); }
- cFlexVar GetValue(const T * temp_target) const { return data_entry->Get(temp_target); }
+ const cString& GetName() const { return m_data_entry->GetName(); }
+ const cString& GetDesc() const { return m_data_entry->GetDesc(); }
+ int GetCompareType() const { return m_data_entry->GetCompareType(); }
+ const cString& GetNull() const { return m_data_entry->GetNull(); }
+ const cString& GetHtmlCellFlags() const { return m_data_entry->GetHtmlCellFlags(); }
- void SetTarget(T * _target) { data_entry->SetTarget(_target); }
- bool SetValue(const cString & value) { return data_entry->Set(value); }
+ bool SetValue(T* target, const cString& value) const { return m_data_entry->Set(target, value); }
+ cFlexVar GetValue(const T* target) const { return m_data_entry->Get(target); }
};
#endif
Modified: development/source/tools/tDataManager.h
===================================================================
--- development/source/tools/tDataManager.h 2008-10-21 17:14:25 UTC (rev 2859)
+++ development/source/tools/tDataManager.h 2008-10-21 18:26:41 UTC (rev 2860)
@@ -31,8 +31,8 @@
#ifndef cDataManager_Base_h
#include "cDataManager_Base.h"
#endif
-#ifndef tDataEntryBase_h
-#include "tDataEntryBase.h"
+#ifndef tDataEntry_h
+#include "tDataEntry.h"
#endif
#ifndef tDictionary_h
#include "tDictionary.h"
@@ -44,37 +44,40 @@
// then be printed to the output file.
class cString;
-template <class T, class U> class tDataEntry;
+template <class TargetType, class EntryType> class tDataEntryOfType;
-template <class T> class tDataManager : public cDataManager_Base {
+template <class TargetType> class tDataManager : public cDataManager_Base
+{
private:
- T * target;
- tDictionary< tDataEntryBase<T> * > entry_dict;
+ TargetType* m_target;
+ tDictionary<tDataEntry<TargetType>*> m_entry_dict;
+
public:
- tDataManager(T * _target, const cString & in_filetype="unknown")
- : cDataManager_Base(in_filetype), target(_target) { ; }
+ tDataManager(TargetType* target, const cString& filetype = "unknown") : cDataManager_Base(filetype), m_target(target) { ; }
~tDataManager() { ; }
- template<class OUT> bool Add(const cString& name, const cString& desc,
- OUT (T::*_funR)() const, void (T::*_funS)(OUT _val) = NULL,
- int compare = 0, const cString& null="0", const cString& html_cell="align=center")
+ template<class EntryType> bool Add(const cString& name, const cString& desc,
+ EntryType (TargetType::*funR)() const, void (TargetType::*funS)(EntryType) = NULL,
+ int compare = 0, const cString& null = "0", const cString& html_cell = "align=center")
{
- tDataEntryBase<T>* new_entry = new tDataEntry<T, OUT> (name, desc, _funR, _funS, compare, null, html_cell);
- new_entry->SetTarget(target);
- entry_dict.Add(name, new_entry);
+ tDataEntry<TargetType>* new_entry =
+ new tDataEntryOfType<TargetType, EntryType>(name, desc, funR, funS, compare, null, html_cell);
+ m_entry_dict.Add(name, new_entry);
return true;
}
- bool Print(const cString & name, std::ostream& fp) {
- tDataEntryBase<T> * cur_entry = NULL;
- if (entry_dict.Find(name, cur_entry) == false) return false;
- fp << cur_entry->Get();
+ bool Print(const cString& name, std::ostream& fp)
+ {
+ tDataEntry<TargetType>* cur_entry = NULL;
+ if (m_entry_dict.Find(name, cur_entry) == false) return false;
+ fp << cur_entry->Get(m_target);
return true;
}
- bool GetDesc(const cString & name, cString & out_desc) {
- tDataEntryBase<T> * cur_entry = NULL;
- if (entry_dict.Find(name, cur_entry) == false) return false;
+ bool GetDesc(const cString& name, cString& out_desc)
+ {
+ tDataEntry<TargetType>* cur_entry = NULL;
+ if (m_entry_dict.Find(name, cur_entry) == false) return false;
out_desc = cur_entry->GetDesc();
return true;
}
More information about the Avida-cvs
mailing list