#ifndef TREE_NODE_HPP
#define TREE_NODE_HPP

#include "Body.hpp"
#include "Box.hpp"
#include "Tree.hpp"
#include "BarnesHutTree.hpp"
#include <cstdlib>
#include <vector>

namespace nbody {
	using namespace std;

	class TreeNode {
		friend void Tree::clean();
		friend void BarnesHutTree::build(vector<Body> bodies);
	protected:
		Box bb;
		vector<Body> bodies;
		TreeNode* prev;
		TreeNode* next;
		TreeNode* afterSubtree;
	public:
		TreeNode();
		virtual ~TreeNode();
		virtual bool isSplitable();
		virtual void extendBBforBodies();
		virtual void extendBBtoCube();
		virtual Box getBB();
		virtual vector<Body> getBodies();
		virtual void insertBefore(TreeNode* node);
		virtual void insertAfter(TreeNode* node);
		virtual void unlink();
	};
}

#endif
