#ifndef TREE_HPP
#define TREE_HPP

#include <vector>
#include <cstdlib>
#include <string>
#include <pthread.h>
#include <stack>
#include "Body.hpp"
#include "Box.hpp"

namespace nbody {
	using namespace std;

	class Node;

	class Tree {
		friend class Node;
	protected:
		Node* nodes;
		unsigned int maxLeafBodies;
	public:
		static vector<Body> dubinskiParse(string filename);

		Tree();
		virtual ~Tree();
		virtual void clean();
		virtual void build(vector<Body> bodies) = 0;
		virtual void build(vector<Body> bodies, Box domain) = 0;
		virtual int numberOfChildren() = 0;
		virtual unsigned long numberOfNodes();
		virtual void accumulateForceOnto(Body& body);
		virtual void computeForces();
		virtual vector<Body> extractLocalBodies();
		virtual vector<Body> copyRefinements(Box domain);
		virtual void rebuild(Box domain);
		virtual Box getRootBB();
		virtual void print();
		virtual bool isCorrect();
		virtual void advance();
		virtual Box getLocalBB();
	};


}

#endif
