New class to automatically cleanup arrays
This commit is contained in:
parent
f142d87b93
commit
e4172f0cea
40
src/loadSimu.hpp
Normal file
40
src/loadSimu.hpp
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user