#ifndef MPI_SIMULATION_HPP
#define MPI_SIMULATION_HPP


#include <mpi.h>
#include "Simulation.hpp"
#include "MpiBodyComm.hpp"
#include "../datastructures/BarnesHutTree.hpp"
#include <vector>

namespace nbody {
	using namespace std;

	class MpiSimulation : public Simulation {
		friend class MpiBodyComm;
	protected:
		int mpiSize;
		int mpiRank;
		MPI_Datatype bodyType;
		MPI_Datatype boxType;
		vector<MpiBodyComm> comms;
		int correctState;
		vector<Body> bodies;
		BarnesHutTree tree;
		Box* domains;

	public:
		MpiSimulation(int& argc, char**& argv);
		virtual ~MpiSimulation();
		virtual void cleanup();
		virtual int getNumberOfProcesses();
		virtual int getProcessId();
		virtual bool stateCorrect();
		virtual bool readInputData(string filename);
		virtual void distributeBodies();
		virtual void distributeDomains();
		virtual void distributeLETs();
		virtual void runStep();
		virtual MPI_Datatype* getDatatype();

	};
}

#endif

