[Avida-cvs] [avida-svn] r883 - in development: Avida.xcodeproj documentation/notes source/event source/main
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Tue Aug 22 13:57:42 PDT 2006
Author: brysonda
Date: 2006-08-22 16:57:42 -0400 (Tue, 22 Aug 2006)
New Revision: 883
Removed:
development/source/event/cEventManager.cc
development/source/event/cEventManager.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/documentation/notes/release-milestones.txt
development/source/event/CMakeLists.txt
development/source/event/SConscript
development/source/event/cEventList.cc
development/source/event/cEventList.h
development/source/main/cAvidaConfig.cc
development/source/main/cWorld.cc
development/source/main/cWorld.h
Log:
Remove cEventManager. Event list calls action library directly to create its events. Some additional cleanup to events would be nice (as in just have a list of actions rather wrapping it), but that will most likely come with the schedulable object framework in 2.7.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2006-08-22 20:34:18 UTC (rev 882)
+++ development/Avida.xcodeproj/project.pbxproj 2006-08-22 20:57:42 UTC (rev 883)
@@ -37,8 +37,6 @@
7039884E09F00D030052ACE7 /* avida.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D509EE8501001AEA89 /* avida.cfg */; };
7039884F09F00D060052ACE7 /* environment.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D709EE8501001AEA89 /* environment.cfg */; };
7039885009F00D080052ACE7 /* events.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D809EE8501001AEA89 /* events.cfg */; };
- 7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
- 7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
70422A28091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
@@ -335,7 +333,6 @@
70DCACEE097AF7CC002F8733 /* cAvidaConfig.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7013846009028B3E0087ED2E /* cAvidaConfig.cc */; };
70DCACEF097AF7CC002F8733 /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
70DCACF0097AF7CC002F8733 /* cHardwareManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BD690905CE5F0028A785 /* cHardwareManager.cc */; };
- 70DCACF1097AF7CC002F8733 /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
70DCACF2097AF7CC002F8733 /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
70DCACF3097AF7CC002F8733 /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
70DCACF4097AF7CC002F8733 /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
@@ -489,8 +486,6 @@
703CA3770A50740300AB4DB4 /* SConscript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConscript; sourceTree = "<group>"; };
703CA3780A50749F00AB4DB4 /* SConstruct */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SConstruct; sourceTree = "<group>"; };
703F684207B437B800C1CA76 /* status.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = status.xml; sourceTree = "<group>"; };
- 7040CF1A0906A52E00AA820F /* cEventManager.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cEventManager.cc; sourceTree = "<group>"; };
- 7040CF1B0906A52E00AA820F /* cEventManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cEventManager.h; sourceTree = "<group>"; };
70422A1C091B141000A5E67F /* cAnalyze.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyze.cc; sourceTree = "<group>"; };
70422A1D091B141000A5E67F /* cAnalyze.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyze.h; sourceTree = "<group>"; };
70422A1E091B141000A5E67F /* cAnalyzeCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommand.h; sourceTree = "<group>"; };
@@ -1335,8 +1330,6 @@
70C1F18808C6A0FA00F50912 /* cEventList.h */,
70C1F18908C6A0FA00F50912 /* cEventListEntry.h */,
70C1F18A08C6A0FA00F50912 /* cEventListIterator.h */,
- 7040CF1A0906A52E00AA820F /* cEventManager.cc */,
- 7040CF1B0906A52E00AA820F /* cEventManager.h */,
70C1F19108C6A11100F50912 /* cEventTriggers.cc */,
70C1F18B08C6A0FA00F50912 /* cEventTriggers.h */,
DCC30FEB0762539D008F7A48 /* CMakeLists.txt */,
@@ -1898,7 +1891,6 @@
7013846209028B3E0087ED2E /* cAvidaConfig.cc in Sources */,
70C5BC6709059A970028A785 /* cWorld.cc in Sources */,
70C5BD6D0905CE5F0028A785 /* cHardwareManager.cc in Sources */,
- 7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */,
70422A28091B141000A5E67F /* cAnalyze.cc in Sources */,
70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
70F7DCA009293E76009E311D /* cClassificationManager.cc in Sources */,
@@ -2036,7 +2028,6 @@
70DCACEE097AF7CC002F8733 /* cAvidaConfig.cc in Sources */,
70DCACEF097AF7CC002F8733 /* cWorld.cc in Sources */,
70DCACF0097AF7CC002F8733 /* cHardwareManager.cc in Sources */,
- 70DCACF1097AF7CC002F8733 /* cEventManager.cc in Sources */,
70DCACF2097AF7CC002F8733 /* cMxCodeArray.cc in Sources */,
70DCACF3097AF7CC002F8733 /* cAnalyze.cc in Sources */,
70DCACF4097AF7CC002F8733 /* cAnalyzeGenotype.cc in Sources */,
@@ -2154,7 +2145,6 @@
7013846409028B3E0087ED2E /* cAvidaConfig.cc in Sources */,
70C5BC6509059A970028A785 /* cWorld.cc in Sources */,
70C5BD6B0905CE5F0028A785 /* cHardwareManager.cc in Sources */,
- 7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */,
7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */,
70422A34091B141000A5E67F /* cAnalyze.cc in Sources */,
70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
Modified: development/documentation/notes/release-milestones.txt
===================================================================
--- development/documentation/notes/release-milestones.txt 2006-08-22 20:34:18 UTC (rev 882)
+++ development/documentation/notes/release-milestones.txt 2006-08-22 20:57:42 UTC (rev 883)
@@ -46,11 +46,11 @@
* Transition all output files to use DataFileManager
* Improved driver object framework
* SMT Hardware
-+ Basic multithreaded analyze mode support
+* Basic multithreaded analyze mode support
* TCMalloc OS X
* TCMalloc Linux
* Actions framework
-+ Merge (meaningful) events and analyze commands into actions framework
+* Merge (meaningful) events and analyze commands into actions framework
* Consistency test support
* Framework for unit testing
* Move UnitTest functions from classes to namespaces
Modified: development/source/event/CMakeLists.txt
===================================================================
--- development/source/event/CMakeLists.txt 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/CMakeLists.txt 2006-08-22 20:57:42 UTC (rev 883)
@@ -1,5 +1,4 @@
SET(libevent_a_SOURCES
- cEventManager.cc
cEventList.cc
cEventTriggers.cc
)
Modified: development/source/event/SConscript
===================================================================
--- development/source/event/SConscript 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/SConscript 2006-08-22 20:57:42 UTC (rev 883)
@@ -8,12 +8,10 @@
'cEventList.h',
'cEventListEntry.h',
'cEventListIterator.h',
- 'cEventManager.h',
'cEventTriggers.h',
]
srcs = [
- 'cEventManager.cc',
'cEventList.cc',
'cEventTriggers.cc',
]
Modified: development/source/event/cEventList.cc
===================================================================
--- development/source/event/cEventList.cc 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/cEventList.cc 2006-08-22 20:57:42 UTC (rev 883)
@@ -11,10 +11,12 @@
#include "cEventList.h"
#include "defs.h"
-#include "cEventManager.h"
+#include "cAction.h"
+#include "cActionLibrary.h"
#include "cEventListEntry.h"
#include "cEventTriggers.h"
#include "cString.h"
+#include "cWorld.h"
#include <float.h> // for DBL_MIN
#include <iostream>
@@ -22,15 +24,9 @@
using namespace std;
-cEventList::cEventList( cEventManager* factory_manager, cEventTriggers *triggers ) :
-m_factory_manager( factory_manager ),
-m_triggers( triggers ),
-m_head(NULL),
-m_tail(NULL),
-m_current(NULL),
-m_num_events(0)
-{
-}
+cEventList::cEventList(cWorld* world, cEventTriggers* triggers)
+: m_world(world), m_triggers(triggers), m_head(NULL), m_tail(NULL), m_current(NULL), m_num_events(0)
+{ ; }
cEventList::~cEventList()
{
@@ -38,19 +34,41 @@
delete m_triggers;
}
-bool
-cEventList::AddEvent( cEventTriggers::eTriggerVariable trigger,
- double start, double interval, double stop,
- const cString & name, const cString & args ){
- assert( m_factory_manager != NULL );
- cEvent *event = m_factory_manager->ConstructEvent( name, args );
+
+class cEventAction : public cEvent
+{
+private:
+ cAction* m_action;
+
+public:
+ cEventAction(cWorld* world, cAction* action, const cString& args)
+ : m_action(action) { Configure(world, args); }
+ ~cEventAction() { delete m_action; }
+ const cString GetName() const { return "action wrapper"; }
+ const cString GetDescription() const { return "action wrapper - description not available"; }
+
+ void Configure(cWorld* world, const cString& in_args) { m_world = world; m_args = in_args; }
+ void Process()
+ {
+ cAvidaContext& ctx = m_world->GetDefaultContext();
+ m_action->Process(ctx);
+ }
+};
+
+
+bool cEventList::AddEvent(cEventTriggers::eTriggerVariable trigger, double start, double interval,
+ double stop, const cString& name, const cString& args)
+{
+ cAction* action = m_world->GetActionLibrary().Create(name, m_world, args);
+
///// Adding Event to the list /////
- if( event != NULL ){
- InsertEvent(event, trigger, start, interval, stop);
+ if (action != NULL) {
+ InsertEvent(new cEventAction(m_world, action, args), trigger, start, interval, stop);
return true;
}
- else return false;
+
+ return false;
}
Modified: development/source/event/cEventList.h
===================================================================
--- development/source/event/cEventList.h 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/cEventList.h 2006-08-22 20:57:42 UTC (rev 883)
@@ -28,21 +28,23 @@
**/
class cEvent;
-class cEventManager;
class cString;
-class cEventList {
-friend class cEventListIterator;
+class cEventList
+{
+ friend class cEventListIterator;
+
public:
cEventListIterator begin() { return cEventListIterator(m_head); }
const cEventListIterator end() const { return cEventListIterator(0); }
+
protected:
- cEventManager *m_factory_manager;
- cEventTriggers *m_triggers;
+ cWorld* m_world;
+ cEventTriggers* m_triggers;
- cEventListEntry *m_head;
- cEventListEntry *m_tail;
- cEventListEntry *m_current;
+ cEventListEntry* m_head;
+ cEventListEntry* m_tail;
+ cEventListEntry* m_current;
int m_num_events;
void InsertEvent(cEvent *event, cEventTriggers::eTriggerVariable trigger,
@@ -59,22 +61,15 @@
cEventList& operator=( const cEventList& );
public:
- // creators
/**
- * The cEventList assumes ownership of both objects it is handed, and
- * destroys them when it is done.
+ * The cEventList assumes ownership of triggers and destroys it when done.
*
- * @param factory_manager A pointer to an event factory manager,
- * @ref cEventFactoryManager. The event factory manager is responsible
- * for finding the appropriate event factory to construct a given event.
- *
* @param triggers A trigger object. The event list needs a trigger object
* to determine what events to call when.
**/
- cEventList( cEventManager *factory_manager, cEventTriggers *triggers );
+ cEventList(cWorld* world, cEventTriggers* triggers);
~cEventList();
- // manipulators
/**
* Adds an event with given name and argument list. The event will be of
* type immediate, i.e. it is processed only once, and then deleted.
@@ -82,8 +77,10 @@
* @param name The name of the event.
* @param args The argument list.
**/
- bool AddEvent( const cString & name, const cString & args ){
- return AddEvent( cEventTriggers::IMMEDIATE, cEventTriggers::TRIGGER_BEGIN, cEventTriggers::TRIGGER_ONCE, cEventTriggers::TRIGGER_END, name, args); }
+ bool AddEvent(const cString& name, const cString& args)
+ {
+ return AddEvent(cEventTriggers::IMMEDIATE, cEventTriggers::TRIGGER_BEGIN, cEventTriggers::TRIGGER_ONCE, cEventTriggers::TRIGGER_END, name, args);
+ }
/**
Deleted: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/cEventManager.cc 2006-08-22 20:57:42 UTC (rev 883)
@@ -1,97 +0,0 @@
-/*
- * cEventManager.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 "cEventManager.h"
-
-#include "cAction.h"
-#include "cActionLibrary.h"
-#include "cAvidaContext.h"
-#include "avida.h"
-#include "cClassificationManager.h"
-#include "cEnvironment.h"
-#include "cEvent.h"
-#include "cGenotype.h"
-#include "cHardwareManager.h"
-#include "cInjectGenotype.h"
-#include "cInstUtil.h"
-#include "cLandscape.h"
-#include "cOrganism.h"
-#include "cPhenotype.h"
-#include "cPopulation.h"
-#include "cPopulationCell.h"
-#include "cResource.h"
-#include "cStats.h"
-#include "cStringUtil.h"
-#include "cTestCPU.h"
-#include "cTestUtil.h"
-#include "cTools.h"
-#include "cWorld.h"
-#include "cWorldDriver.h"
-
-#include <ctype.h> // for isdigit
-#include <iostream>
-
-using namespace std;
-
-
-
-class cEventAction : public cEvent
-{
-private:
- cAction* m_action;
-
-public:
- cEventAction(cWorld* world, cAction* action, const cString& args)
- : m_action(action) { Configure(world, args); }
- ~cEventAction() { delete m_action; }
-
- const cString GetName() const { return "action wrapper"; }
- const cString GetDescription() const { return "action wrapper - description not available"; }
-
- void Configure(cWorld* world, const cString& in_args) { m_world = world; m_args = in_args; }
- void Process()
- {
- cAvidaContext& ctx = m_world->GetDefaultContext();
- m_action->Process(ctx);
- }
-};
-
-
-
-#define REGISTER(EVENT_NAME) Register<cEvent_ ## EVENT_NAME>(#EVENT_NAME)
-
-cEventManager::cEventManager(cWorld* world) : m_world(world)
-{
-}
-
-cEvent* cEventManager::ConstructEvent(const cString name, const cString& args)
-{
- cEvent* event = Create(name);
-
- if (event != NULL) {
- event->Configure(m_world, args);
- } else {
- cAction* action = m_world->GetActionLibrary().Create(name, m_world, args);
- if (action != NULL) event = new cEventAction(m_world, action, args);
- }
-
- return event;
-}
-
-void cEventManager::PrintAllEventDescriptions()
-{
- tArray<cEvent*> events;
- CreateAll(events);
-
- for (int i = 0; i < events.GetSize(); i++) {
- cout << events[i]->GetDescription() << endl;
- delete events[i];
- }
-}
Deleted: development/source/event/cEventManager.h
===================================================================
--- development/source/event/cEventManager.h 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/event/cEventManager.h 2006-08-22 20:57:42 UTC (rev 883)
@@ -1,52 +0,0 @@
-/*
- * cEventManager.h
- * Avida
- *
- * Created by David on 12/2/05.
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- */
-
-#ifndef cEventManager_h
-#define cEventManager_h
-
-#ifndef tList_h
-#include "tList.h"
-#endif
-#ifndef tObjectFactory_h
-#include "tObjectFactory.h"
-#endif
-#ifndef cString_h
-#include "cString.h"
-#endif
-
-class cEvent;
-class cWorld;
-
-class cEventManager : private tObjectFactory<cEvent* ()> {
-private:
- cWorld* m_world;
-
-public:
- cEventManager(cWorld* world);
- ~cEventManager() { ; }
-
- cEvent* ConstructEvent(const cString name, const cString& args);
-
- void PrintAllEventDescriptions();
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nEventManager {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-#endif
Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/main/cAvidaConfig.cc 2006-08-22 20:57:42 UTC (rev 883)
@@ -12,7 +12,6 @@
#include <fstream>
#include "defs.h"
-#include "cEventManager.h"
#include "cInitFile.h"
#include "tDictionary.h"
@@ -301,13 +300,17 @@
cString cur_arg = args[arg_num];
// Test against the possible inputs.
- if (cur_arg == "-events" || cur_arg == "-e") {
- cout << "Known events:" << endl;
- cEventManager event_manager(NULL);
- event_manager.PrintAllEventDescriptions();
- exit(0);
- }
- else if (cur_arg == "--help" || cur_arg == "-help" || cur_arg == "-h") {
+
+// @DMB - todo: print out all now *actions*
+//
+// if (cur_arg == "-events" || cur_arg == "-e") {
+// cout << "Known events:" << endl;
+// cEventManager event_manager(NULL);
+// event_manager.PrintAllEventDescriptions();
+// exit(0);
+// } else
+
+ if (cur_arg == "--help" || cur_arg == "-help" || cur_arg == "-h") {
cout << "Options:"<<endl
<< " -c[onfig] <filename> Set config file to be <filename>"<<endl
<< " -h[elp] Help on options (this listing)"<<endl
Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/main/cWorld.cc 2006-08-22 20:57:42 UTC (rev 883)
@@ -15,7 +15,6 @@
#include "cClassificationManager.h"
#include "cEnvironment.h"
#include "cEventList.h"
-#include "cEventManager.h"
#include "cHardwareManager.h"
#include "cInitFile.h"
#include "cPopulation.h"
@@ -34,7 +33,6 @@
delete m_conf;
delete m_data_mgr;
delete m_env;
- delete m_event_mgr;
delete m_event_list;
delete m_hw_mgr;
delete m_pop;
@@ -75,9 +73,8 @@
m_stats = new cStats(this);
m_pop = new cPopulation(this);
- //Setup Event List
- m_event_mgr = new cEventManager(this);
- m_event_list = new cEventList(m_event_mgr, new cAvidaTriggers(*m_stats) );
+ // Setup Event List
+ m_event_list = new cEventList(this, new cAvidaTriggers(*m_stats));
ReadEventListFile(m_conf->EVENT_FILE.Get());
Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h 2006-08-22 20:34:18 UTC (rev 882)
+++ development/source/main/cWorld.h 2006-08-22 20:57:42 UTC (rev 883)
@@ -28,7 +28,6 @@
class cAvidaDriver;
class cClassificationManager;
class cEnvironment;
-class cEventManager;
class cEventList;
class cHardwareManager;
class cPopulation;
@@ -46,7 +45,6 @@
cClassificationManager* m_class_mgr;
cDataFileManager* m_data_mgr;
cEnvironment* m_env;
- cEventManager* m_event_mgr;
cEventList* m_event_list;
cHardwareManager* m_hw_mgr;
cPopulation* m_pop;
@@ -117,7 +115,6 @@
a.ArkvObj("m_class_mgr", m_class_mgr);
a.ArkvObj("m_data_mgr", m_data_mgr);
a.ArkvObj("m_env", m_env);
- a.ArkvObj("m_event_mgr", m_event_mgr);
a.ArkvObj("m_event_list", m_event_list);
a.ArkvObj("m_hw_mgr", m_hw_mgr);
a.ArkvObj("m_pop", m_pop);
@@ -142,7 +139,6 @@
a.ArkvObj("m_class_mgr", m_class_mgr);
a.ArkvObj("m_data_mgr", m_data_mgr);
a.ArkvObj("m_env", m_env);
- a.ArkvObj("m_event_mgr", m_event_mgr);
a.ArkvObj("m_event_list", m_event_list);
a.ArkvObj("m_hw_mgr", m_hw_mgr);
a.ArkvObj("m_pop", m_pop);
More information about the Avida-cvs
mailing list