[Avida-SVN] r1127 - in development: . source/actions source/analyze source/classification source/cpu source/drivers source/main source/tools
avidaedward at myxo.css.msu.edu
avidaedward at myxo.css.msu.edu
Mon Dec 11 19:29:33 PST 2006
Author: avidaedward
Date: 2006-12-11 22:29:32 -0500 (Mon, 11 Dec 2006)
New Revision: 1127
Modified:
development/
development/source/actions/cActionLibrary.h
development/source/analyze/cAnalyze.h
development/source/classification/cClassificationManager.h
development/source/cpu/cHardwareManager.h
development/source/drivers/cDefaultAnalyzeDriver.h
development/source/drivers/cWorldDriver.h
development/source/main/cAvidaConfig.h
development/source/main/cAvidaContext.h
development/source/main/cEnvironment.h
development/source/main/cEventList.h
development/source/main/cPopulation.h
development/source/main/cStats.h
development/source/main/cWorld.cc
development/source/main/cWorld.h
development/source/tools/cDataFileManager.h
Log:
r1138 at Kaben-Nanlohys-MacBook-Pro-15: kaben | 2006-12-11 22:32:30 -0500
Discovery: driver objects take ownership of world objects; i.e., driver deletes world object.
Property changes on: development
___________________________________________________________________
Name: svk:merge
- 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/development:1121
+ 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/development:1138
Modified: development/source/actions/cActionLibrary.h
===================================================================
--- development/source/actions/cActionLibrary.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/actions/cActionLibrary.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -17,11 +17,21 @@
#include "tObjectFactory.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cWorld;
class cString;
class cActionLibrary
{
+#if USE_tMemTrack
+ tMemTrack<cActionLibrary> mt;
+#endif
private:
typedef const cString (*ClassDescFunction)();
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/analyze/cAnalyze.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -38,6 +38,13 @@
#include "tMatrix.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
const int MAX_BATCHES = 2000;
class cAnalyzeCommand;
@@ -55,6 +62,9 @@
class cAnalyze
{
+#if USE_tMemTrack
+ tMemTrack<cAnalyze> mt;
+#endif
/*
FIXME : switch back to private.
- switched to public while I brainstorm. @kgn 06.11.22
Modified: development/source/classification/cClassificationManager.h
===================================================================
--- development/source/classification/cClassificationManager.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/classification/cClassificationManager.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -35,6 +35,13 @@
#include "tList.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cAvidaContext;
class cLineage;
class cOrganism;
@@ -42,6 +49,9 @@
class cClassificationManager
{
+#if USE_tMemTrack
+ tMemTrack<cClassificationManager> mt;
+#endif
private:
cWorld* m_world;
Modified: development/source/cpu/cHardwareManager.h
===================================================================
--- development/source/cpu/cHardwareManager.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/cpu/cHardwareManager.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -17,12 +17,22 @@
#include "cTestCPU.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cOrganism;
class cHardwareBase;
class cWorld;
class cHardwareManager
{
+#if USE_tMemTrack
+ tMemTrack<cHardwareManager> mt;
+#endif
private:
cWorld* m_world;
cInstSet m_inst_set;
Modified: development/source/drivers/cDefaultAnalyzeDriver.h
===================================================================
--- development/source/drivers/cDefaultAnalyzeDriver.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/drivers/cDefaultAnalyzeDriver.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -17,11 +17,21 @@
#include "cWorldDriver.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cString;
class cWorld;
class cDefaultAnalyzeDriver : public cAvidaDriver, public cWorldDriver
{
+#if USE_tMemTrack
+ tMemTrack<cDefaultAnalyzeDriver> mt;
+#endif
private:
cDefaultAnalyzeDriver(); // @not_implemented
cDefaultAnalyzeDriver(const cDefaultAnalyzeDriver&); // @not_implemented
Modified: development/source/drivers/cWorldDriver.h
===================================================================
--- development/source/drivers/cWorldDriver.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/drivers/cWorldDriver.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -13,10 +13,20 @@
// This class is an abstract base class that is used by actions within
// a cWorld to notify its driver of various states and conditions.
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cString;
class cWorldDriver
{
+#if USE_tMemTrack
+ tMemTrack<cWorldDriver> mt;
+#endif
private:
cWorldDriver(const cWorldDriver&); // @not_implemented
cWorldDriver& operator=(const cWorldDriver&); // @not_implemented
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cAvidaConfig.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -23,6 +23,13 @@
#include "cStringUtil.h"
#include "tList.h"
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
using namespace std;
@@ -86,6 +93,9 @@
} NAME \
class cAvidaConfig {
+#if USE_tMemTrack
+ tMemTrack<cAvidaConfig> mt;
+#endif
private:
// The cBaseConfigEntry class is a bass class for all configuration entries.
// It is used to manage the various types of entries in a dynamic fashion.
Modified: development/source/main/cAvidaContext.h
===================================================================
--- development/source/main/cAvidaContext.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cAvidaContext.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -10,10 +10,20 @@
#ifndef cAvidaContext_h
#define cAvidaContext_h
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cRandom;
class cAvidaContext
{
+#if USE_tMemTrack
+ tMemTrack<cAvidaContext> mt;
+#endif
private:
cRandom* m_rng;
bool m_analyze;
Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cEnvironment.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -36,6 +36,13 @@
#include "tList.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cAvidaContext;
class cReaction;
class cReactionRequisite;
@@ -47,6 +54,9 @@
class cWorld;
class cEnvironment {
+#if USE_tMemTrack
+ tMemTrack<cEnvironment> mt;
+#endif
private:
cWorld* m_world;
Modified: development/source/main/cEventList.h
===================================================================
--- development/source/main/cEventList.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cEventList.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -15,6 +15,13 @@
#include "cAction.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cAvidaContext;
class cString;
class cWorld;
@@ -26,6 +33,9 @@
class cEventList
{
+#if USE_tMemTrack
+ tMemTrack<cEventList> mt;
+#endif
public:
enum eTriggerType { UPDATE, GENERATION, IMMEDIATE, UNDEFINED };
Modified: development/source/main/cPopulation.h
===================================================================
--- development/source/main/cPopulation.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cPopulation.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -41,6 +41,13 @@
#include "tList.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cAvidaContext;
class cCodeLabel;
class cChangeList;
@@ -56,6 +63,9 @@
class cPopulation
{
+#if USE_tMemTrack
+ tMemTrack<cPopulation> mt;
+#endif
private:
// Components...
cWorld* m_world;
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cStats.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -40,12 +40,22 @@
#include "nGeometry.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
class cGenotype;
class cInjectGenotype;
class cWorld;
class cStats
{
+#if USE_tMemTrack
+ tMemTrack<cStats> mt;
+#endif
private:
cWorld* m_world;
Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cWorld.cc 2006-12-12 03:29:32 UTC (rev 1127)
@@ -21,23 +21,29 @@
#include "cTools.h"
#include "cFallbackWorldDriver.h"
+#include <assert.h>
+
cWorld::~cWorld()
{
- m_data_mgr->FlushAll();
+ if(m_data_mgr) { m_data_mgr->FlushAll(); }
+ if(m_pop){ delete m_pop; m_pop=0; }
+
// m_actlib is not owned by cWorld, DO NOT DELETE
- delete m_analyze;
- delete m_conf;
- delete m_data_mgr;
- delete m_env;
- delete m_event_list;
- delete m_hw_mgr;
- delete m_pop;
- delete m_stats;
+ if(m_analyze){ delete m_analyze; m_analyze=0; }
+ if(m_conf){ delete m_conf; m_conf=0; }
+ if(m_data_mgr){ delete m_data_mgr; m_data_mgr=0; }
+ if(m_env){ delete m_env; m_env=0; }
+ if(m_event_list){ delete m_event_list; m_event_list=0; }
+ // must occur *after* m_pop is deleted. @kgn
+ if(m_hw_mgr){ delete m_hw_mgr; m_hw_mgr=0; }
+ if(m_class_mgr){ delete m_class_mgr; m_class_mgr=0; }
+ if(m_stats){ delete m_stats; m_stats=0; }
// cleanup driver object, if needed
- if (m_own_driver) delete m_driver;
+ if (m_own_driver) { assert(m_driver); delete m_driver; m_driver=0; }
+
}
void cWorld::Setup()
@@ -127,7 +133,7 @@
void cWorld::SetDriver(cWorldDriver* driver, bool take_ownership)
{
// cleanup current driver, if needed
- if (m_own_driver) delete m_driver;
+ if (m_own_driver) { assert(m_driver); delete m_driver; m_driver=0; }
// store new driver information
m_driver = driver;
Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/main/cWorld.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -23,6 +23,15 @@
#include "cRandom.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
+#include <assert.h>
+
class cActionLibrary;
class cAnalyze;
class cAvidaDriver;
@@ -37,6 +46,9 @@
class cWorld
{
+#if USE_tMemTrack
+ tMemTrack<cWorld> mt;
+#endif
protected:
cActionLibrary* m_actlib;
cAnalyze* m_analyze;
@@ -65,11 +77,24 @@
cWorld& operator=(const cWorld&); // @not_implemented
public:
- explicit cWorld() : m_analyze(NULL), m_conf(new cAvidaConfig()), m_ctx(m_rng) { Setup(); }
+ explicit cWorld()
+ : m_actlib(NULL)
+ , m_analyze(NULL)
+ , m_conf(new cAvidaConfig())
+ , m_ctx(m_rng)
+ , m_class_mgr(NULL)
+ , m_data_mgr(NULL)
+ , m_env(NULL)
+ , m_event_list(NULL)
+ , m_hw_mgr(NULL)
+ , m_pop(NULL)
+ , m_stats(NULL)
+ , m_driver(NULL)
+ { Setup(); }
cWorld(cAvidaConfig* cfg) : m_analyze(NULL), m_conf(cfg), m_ctx(m_rng) { Setup(); }
~cWorld();
- void SetConfig(cAvidaConfig* cfg) { delete m_conf; m_conf = cfg; }
+ void SetConfig(cAvidaConfig* cfg) { assert(m_conf); delete m_conf; m_conf = cfg; }
void SetDriver(cWorldDriver* driver, bool take_ownership = false);
// General Object Accessors
Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h 2006-12-12 03:27:04 UTC (rev 1126)
+++ development/source/tools/cDataFileManager.h 2006-12-12 03:29:32 UTC (rev 1127)
@@ -20,6 +20,13 @@
#include "tDictionary.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
/**
* This class helps to manage a collection of data files. It is possible
* to add files, to remove files, and to access existing files by name.
@@ -30,6 +37,9 @@
template <class T> class tList; // aggregate
class cDataFileManager {
+#if USE_tMemTrack
+ tMemTrack<cDataFileManager> mt;
+#endif
private:
cString m_target_dir;
tDictionary<cDataFile*> m_datafiles;
More information about the Avida-cvs
mailing list