#ifndef ATS_MBOIDGLOBAL_H
#define ATS_MBOIDGLOBAL_H

#include <maya/MString.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>
#include <maya/MDagPath.h>
#include <vector>
#include <algorithm>
#include <ostream>
#include "ats_BoidGroup.h"
#include "ats_MException.h"

namespace ats
{
	/* 引数解析用パッケージ */
	struct StructArg
	{
		StructArg(char* s, int n)
		: str(s), num(n) {
			val = new double[num];
			for(int i=0; i<num; i++){ val[i] = 0; }
		}
		~StructArg(){ delete [] val; }
		MString  str; // "-w"etc
		int      num; // 引数の数
		double*  val; // 引数が格納されるポインタ
		bool operator==(const MString& a) const {
			return str == a;
		}
	private:
		// 面倒臭いから隠す
		StructArg(const StructArg&);
		StructArg& operator=(const StructArg&);
	};

	template <class T>
	T rad(T deg){
		return deg * 3.1415926535897932384626433832795 / 180;
	}

	void GetFirstSelection(MDagPath* path, MObject* obj) throw (MException);
	void MakeMayaBoid(BoidGroup* group, int copy_number, const StructArg& weight, const StructArg& ball, const StructArg& speed) throw (MException);
	void ParseArg(const MArgList& args, std::vector<StructArg*>* arg_pack) throw (MException);
}

std::ostream& operator<<(std::ostream& out, const MString& a);
std::ostream& operator<<(std::ostream& out, const MStringArray& a);
std::ostream& operator<<(std::ostream& out, const ats::StructArg& a);
// vectorにStructArgのポインタを喰わせたため定義。
bool operator==(const ats::StructArg* a, const MString& b);

#endif
