[Avida-cvs] [avida-svn] r845 - in development: Avida.xcodeproj source/actions source/event
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Jul 20 11:43:25 PDT 2006
Author: brysonda
Date: 2006-07-20 14:43:25 -0400 (Thu, 20 Jul 2006)
New Revision: 845
Added:
development/source/actions/DriverActions.cc
development/source/actions/DriverActions.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/actions/CMakeLists.txt
development/source/actions/SConscript
development/source/actions/cActionLibrary.cc
development/source/event/cEventManager.cc
Log:
Move various driver related events into actions. Namely exit and exit lineage label (greater and less).
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2006-07-19 20:00:57 UTC (rev 844)
+++ development/Avida.xcodeproj/project.pbxproj 2006-07-20 18:43:25 UTC (rev 845)
@@ -57,6 +57,9 @@
7049F3710A66AD7E00640512 /* default-sex-classic.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36D0A66AD7E00640512 /* default-sex-classic.org */; };
7049F3720A66AD7E00640512 /* default-smt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36E0A66AD7E00640512 /* default-smt.org */; };
7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36F0A66AD7E00640512 /* default-transsmt.org */; };
+ 704ADBC60A6EEFC300666970 /* DriverActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704ADBC40A6EEFC300666970 /* DriverActions.cc */; };
+ 704ADBC80A6EEFC300666970 /* DriverActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704ADBC40A6EEFC300666970 /* DriverActions.cc */; };
+ 704ADBF90A6EF3A300666970 /* DriverActions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704ADBC40A6EEFC300666970 /* DriverActions.cc */; };
7053324C0929764C006BD186 /* cSpecies.cc in Sources */ = {isa = PBXBuildFile; fileRef = 705332480929764A006BD186 /* cSpecies.cc */; };
7053324D0929764E006BD186 /* cSpeciesQueue.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7053324A0929764A006BD186 /* cSpeciesQueue.cc */; };
7053336D092A3DF9006BD186 /* cInjectGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70533364092A3DF4006BD186 /* cInjectGenotype.cc */; };
@@ -511,6 +514,8 @@
7049F36D0A66AD7E00640512 /* default-sex-classic.org */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "default-sex-classic.org"; sourceTree = "<group>"; };
7049F36E0A66AD7E00640512 /* default-smt.org */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "default-smt.org"; sourceTree = "<group>"; };
7049F36F0A66AD7E00640512 /* default-transsmt.org */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "default-transsmt.org"; sourceTree = "<group>"; };
+ 704ADBC30A6EEFC300666970 /* DriverActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DriverActions.h; sourceTree = "<group>"; };
+ 704ADBC40A6EEFC300666970 /* DriverActions.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DriverActions.cc; sourceTree = "<group>"; };
705332480929764A006BD186 /* cSpecies.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cSpecies.cc; sourceTree = "<group>"; };
705332490929764A006BD186 /* cSpecies.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cSpecies.h; sourceTree = "<group>"; };
7053324A0929764A006BD186 /* cSpeciesQueue.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cSpeciesQueue.cc; sourceTree = "<group>"; };
@@ -1025,6 +1030,8 @@
708051BA0A1F66B400CBB8B6 /* cActionLibrary.cc */,
70C054C80A4F6E19002703C1 /* PopulationActions.h */,
70C054C90A4F6E19002703C1 /* PopulationActions.cc */,
+ 704ADBC30A6EEFC300666970 /* DriverActions.h */,
+ 704ADBC40A6EEFC300666970 /* DriverActions.cc */,
);
path = actions;
sourceTree = "<group>";
@@ -1940,6 +1947,7 @@
70C054FA0A4F7053002703C1 /* PopulationActions.cc in Sources */,
709D924E0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */,
7049F2DB0A66859F00640512 /* cHardwareTransSMT.cc in Sources */,
+ 704ADBC80A6EEFC300666970 /* DriverActions.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2071,6 +2079,7 @@
70C054F90A4F704E002703C1 /* SaveLoadActions.cc in Sources */,
709D924D0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */,
7049F2DA0A66859B00640512 /* cHardwareTransSMT.cc in Sources */,
+ 704ADBC60A6EEFC300666970 /* DriverActions.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2183,6 +2192,7 @@
70C054ED0A4F6FD2002703C1 /* PopulationActions.cc in Sources */,
709D924C0A5D950D00D6A163 /* cMutationalNeighborhood.cc in Sources */,
7049F2D90A66859700640512 /* cHardwareTransSMT.cc in Sources */,
+ 704ADBF90A6EF3A300666970 /* DriverActions.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: development/source/actions/CMakeLists.txt
===================================================================
--- development/source/actions/CMakeLists.txt 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/actions/CMakeLists.txt 2006-07-20 18:43:25 UTC (rev 845)
@@ -2,6 +2,7 @@
SET(libactions_a_SOURCES
cActionLibrary.cc
+ DriverActions.cc
LandscapeActions.cc
PopulationActions.cc
PrintActions.cc
Added: development/source/actions/DriverActions.cc
===================================================================
--- development/source/actions/DriverActions.cc 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/actions/DriverActions.cc 2006-07-20 18:43:25 UTC (rev 845)
@@ -0,0 +1,79 @@
+/*
+ * DriverActions.cc
+ * Avida
+ *
+ * Created by David Bryson on 7/19/06.
+ * Copyright 2006 Michigan State University. All rights reserved.
+ *
+ */
+
+#include "DriverActions.h"
+
+#include "cAction.h"
+#include "cActionLibrary.h"
+#include "cStats.h"
+#include "cWorld.h"
+#include "cWorldDriver.h"
+
+class cActionExit : public cAction
+{
+public:
+ cActionExit(cWorld* world, const cString& args) : cAction(world, args) { ; }
+ const cString GetDescription() { return "Exit"; }
+ void Process(cAvidaContext& ctx) { m_world->GetDriver().SetDone(); }
+};
+
+class cActionExitAveLineageLabelGreater : public cAction
+{
+private:
+ double m_threshold;
+public:
+ cActionExitAveLineageLabelGreater(cWorld* world, const cString& args) : cAction(world, args), m_threshold(0.0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_threshold = largs.PopWord().AsDouble();
+ }
+
+ const cString GetDescription() { return "ExitAveLineageLabelGreater <double threshold>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ if (m_world->GetStats().GetAveLineageLabel() > m_threshold) {
+ m_world->GetDriver().SetDone();
+ }
+ }
+};
+
+class cActionExitAveLineageLabelLess : public cAction
+{
+private:
+ double m_threshold;
+public:
+ cActionExitAveLineageLabelLess(cWorld* world, const cString& args) : cAction(world, args), m_threshold(0.0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_threshold = largs.PopWord().AsDouble();
+ }
+
+ const cString GetDescription() { return "ExitAveLineageLabelLess <double threshold>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ if (m_world->GetStats().GetAveLineageLabel() < m_threshold) {
+ m_world->GetDriver().SetDone();
+ }
+ }
+};
+
+
+void RegisterDriverActions(cActionLibrary* action_lib)
+{
+ action_lib->Register<cActionExit>("Exit");
+ action_lib->Register<cActionExitAveLineageLabelGreater>("ExitAveLineageLabelGreater");
+ action_lib->Register<cActionExitAveLineageLabelLess>("ExitAveLineageLabelLess");
+
+ // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
+ action_lib->Register<cActionExit>("exit");
+ action_lib->Register<cActionExitAveLineageLabelGreater>("exit_if_ave_lineage_label_larger");
+ action_lib->Register<cActionExitAveLineageLabelLess>("exit_if_ave_lineage_label_smaller");
+}
Added: development/source/actions/DriverActions.h
===================================================================
--- development/source/actions/DriverActions.h 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/actions/DriverActions.h 2006-07-20 18:43:25 UTC (rev 845)
@@ -0,0 +1,17 @@
+/*
+ * DriverActions.h
+ * Avida
+ *
+ * Created by David Bryson on 7/19/06.
+ * Copyright 2006 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef DriverActions_h
+#define DriverActions_h
+
+class cActionLibrary;
+
+void RegisterDriverActions(cActionLibrary* action_lib);
+
+#endif
Modified: development/source/actions/SConscript
===================================================================
--- development/source/actions/SConscript 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/actions/SConscript 2006-07-20 18:43:25 UTC (rev 845)
@@ -6,6 +6,7 @@
incs = [
'cAction.h',
'cActionLibrary.h',
+ 'DriverActions.h',
'LandscapeActions.h',
'PopulationActions.h',
'PrintActions.h',
@@ -14,6 +15,7 @@
srcs = [
'cActionLibrary.cc',
+ 'DriverActions.cc',
'LandscapeActions.cc',
'PopulationActions.cc',
'PrintActions.cc',
Modified: development/source/actions/cActionLibrary.cc
===================================================================
--- development/source/actions/cActionLibrary.cc 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/actions/cActionLibrary.cc 2006-07-20 18:43:25 UTC (rev 845)
@@ -9,6 +9,7 @@
#include "cActionLibrary.h"
+#include "DriverActions.h"
#include "LandscapeActions.h"
#include "PopulationActions.h"
#include "PrintActions.h"
@@ -19,6 +20,7 @@
{
cActionLibrary* actlib = new cActionLibrary();
+ RegisterDriverActions(actlib);
RegisterLandscapeActions(actlib);
RegisterPopulationActions(actlib);
RegisterPrintActions(actlib);
Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc 2006-07-19 20:00:57 UTC (rev 844)
+++ development/source/event/cEventManager.cc 2006-07-20 18:43:25 UTC (rev 845)
@@ -42,154 +42,6 @@
using namespace std;
-
-class cEvent_exit : public cEvent {
-public:
- const cString GetName() const { return "exit"; }
- const cString GetDescription() const { return "exit"; }
-
- void Configure(cWorld* world, const cString& in_args) { m_world = world; }
- void Process(){
- m_world->GetDriver().SetDone();
- }
-};
-
-///// exit_if_generation_greater_than /////
-
-/**
-* Ends the Avida run when the current generation exceeds the
- * maximum generation given as parameter.
- *
- * Parameters:
- * max generation (int)
- * The generation at which the run should be stopped.
- **/
-class cEvent_exit_if_generation_greater_than : public cEvent {
-private:
- int max_generation;
-public:
- const cString GetName() const { return "exit_if_generation_greater_than"; }
- const cString GetDescription() const { return "exit_if_generation_greater_than <int max_generation>"; }
-
- void Configure(cWorld* world, const cString& in_args)
- {
- m_world = world;
- m_args = in_args;
- cString args(in_args);
- max_generation = args.PopWord().AsInt();
- }
- ///// exit_if_generation_greater_than /////
- void Process(){
- if( m_world->GetStats().SumGeneration().Average() > max_generation ){
- m_world->GetDriver().SetDone();
- }
- }
-};
-
-///// exit_if_update_greater_than /////
-
-/**
-* Ends the Avida run when the current update exceeds the
- * maximum update given as parameter.
- *
- * Parameters:
- * max update (int)
- * The update at which the run should be stopped.
- **/
-
-
-class cEvent_exit_if_update_greater_than : public cEvent {
-private:
- int max_update;
-public:
- const cString GetName() const { return "exit_if_update_greater_than"; }
- const cString GetDescription() const { return "exit_if_update_greater_than <int max_update>"; }
-
- void Configure(cWorld* world, const cString& in_args)
- {
- m_world = world;
- m_args = in_args;
- cString args(in_args);
- max_update = args.PopWord().AsInt();
- }
- ///// exit_if_update_greater_than /////
- void Process(){
- if( m_world->GetStats().GetUpdate() > max_update ){
- m_world->GetDriver().SetDone();
- }
- }
-};
-
-///// exit_if_ave_lineage_label_smaller /////
-
-/**
-* Halts the avida run if the current average lineage label is smaller
- * than the value given as parameter.
- *
- * Parameters:
- * lineage_label_crit_value (int)
- * The critical value to which the average lineage label is compared.
- **/
-
-
-class cEvent_exit_if_ave_lineage_label_smaller : public cEvent {
-private:
- double lineage_label_crit_value;
-public:
- const cString GetName() const { return "exit_if_ave_lineage_label_smaller"; }
- const cString GetDescription() const { return "exit_if_ave_lineage_label_smaller <double lineage_label_crit_value>"; }
-
- void Configure(cWorld* world, const cString& in_args)
- {
- m_world = world;
- m_args = in_args;
- cString args(in_args);
- lineage_label_crit_value = args.PopWord().AsDouble();
- }
- ///// exit_if_ave_lineage_label_smaller /////
- void Process(){
- if( m_world->GetStats().GetAveLineageLabel() < lineage_label_crit_value ){
- m_world->GetDriver().SetDone();
- }
- }
-};
-
-///// exit_if_ave_lineage_label_larger /////
-
-/**
-* Halts the avida run if the current average lineage label is larger
- * than the value given as parameter.
- *
- * Parameters:
- * lineage_label_crit_value (int)
- * The critical value to which the average lineage label is compared.
- **/
-
-
-class cEvent_exit_if_ave_lineage_label_larger : public cEvent {
-private:
- double lineage_label_crit_value;
-public:
- const cString GetName() const { return "exit_if_ave_lineage_label_larger"; }
- const cString GetDescription() const { return "exit_if_ave_lineage_label_larger <double lineage_label_crit_value>"; }
-
- void Configure(cWorld* world, const cString& in_args)
- {
- m_world = world;
- m_args = in_args;
- cString args(in_args);
- lineage_label_crit_value = args.PopWord().AsDouble();
- }
- ///// exit_if_ave_lineage_label_larger /////
- void Process(){
- if( m_world->GetStats().GetAveLineageLabel() > lineage_label_crit_value ){
- m_world->GetDriver().SetDone();
- }
- }
-};
-
-
-
///// zero_muts /////
/**
@@ -1651,12 +1503,6 @@
cEventManager::cEventManager(cWorld* world) : m_world(world)
{
- REGISTER(exit);
- REGISTER(exit_if_generation_greater_than);
- REGISTER(exit_if_update_greater_than);
- REGISTER(exit_if_ave_lineage_label_smaller);
- REGISTER(exit_if_ave_lineage_label_larger);
-
REGISTER(zero_muts);
REGISTER(mod_copy_mut);
REGISTER(mod_div_mut);
More information about the Avida-cvs
mailing list