#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:
		unsigned int mpiSize;
		unsigned int mpiRank;
		MPI::Datatype bodyType;
		MPI::Datatype boxType;
		vector<MpiBodyComm> comms;
		bool 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 runStep();
		virtual MPI::Datatype* getDatatype();

	};
}

#endif

