From e4172f0cea0c5a36af46f9fad444169381162606 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 27 Apr 2010 13:41:41 +0200 Subject: [PATCH] New class to automatically cleanup arrays --- src/loadSimu.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/loadSimu.hpp diff --git a/src/loadSimu.hpp b/src/loadSimu.hpp new file mode 100644 index 0000000..1215a88 --- /dev/null +++ b/src/loadSimu.hpp @@ -0,0 +1,40 @@ +#ifndef __COSMOTOOLBOX_HPP +#define __COSMOTOOLBOX_HPP + + +namespace CosmoTool +{ + static const int NEED_GADGET_ID = 1; + static const int NEED_POSITION = 2; + static const int NEED_VELOCITY = 4; + + + class SimuData + { + public: + float BoxSize; + float time; + + long NumPart; + int *Id; + float *Pos[3]; + float *Vel[3]; + public: + SimuData() : Id(0),NumPart(0) { Pos[0]=Pos[1]=Pos[2]=0; Vel[0]=Vel[1]=Vel[2]=0; } + ~SimuData() + { + for (int j = 0; j < 3; j++) + { + if (Pos[j]) + delete[] Pos[j]; + if (Vel[j]) + delete[] Vel[j]; + } + if (Id) + delete[] Id; + } + }; + +}; + +#endif