#include "pikbdlistener.h"
#include "piconnection.h"
#include "piconfig.h"
#include "piscreentiles.h"
#include "piscreen.h"
#include "piethernet.h"
#include "piintrospection.h"
#include "pifile.h"

//struct MS {
//	//MS() {i = 0; f = 0.;}
//	int i;
//	float f;
//	PIString s;
//};

//PIByteArray & operator<<(PIByteArray & ba, const MS & v) {ba << v.i << v.f << v.s; return ba;}
//PIByteArray & operator>>(PIByteArray & ba, MS & v) {ba >> v.i >> v.f >> v.s; return ba;}
//PICout operator <<(PICout c, const MS & v) {c << "(" << v.i << v.f << v.s << ")"; return c;}

//REGISTER_VARIANT(MS)
//REGISTER_VARIANT_CAST(MS, int) {return v.i;}
//REGISTER_VARIANT_CAST(MS, float) {return v.f;}
//REGISTER_VARIANT_CAST(MS, PIString) {return v.s;}
template <uint N = 3u, typename T = double>
class VC {
public:
	T v[N];
	VC(T x) {for (uint i=0; i<N; i++) v[i] = x;}
	T dot(VC<N, T> a) {T res = T(); for (uint i=0; i<N; i++) res += v[i] * a.v[N - i - 1]; return res;}
};

int main (int argc, char * argv[]) {
	VC<30, double> x(1.5), y(3.3);
	double r = 0.0;
	PITimeMeasurer tm;
	for (int i=0; i<10000; i++)
		r = x.dot(y);
	piCout << r << tm.elapsed_m();
	//PIByteArray ba;
	/*PIKbdListener kbd;
	kbd.enableExitCapture();
	PIString str;
	str.reserve(1024*1024);
	PIINTROSPECTION_START
	//piCout << PIINTROSPECTION_CONTAINERS->count;
	WAIT_FOR_EXIT*/
//	PIVector<PIVariant> vl;
//	vl << PIVariant('2') << PIVariant(-5.5) << PIVariant(10) << PIVariant(complexd(2,3)) << PIVariant("text") << PIVariant(PIByteArray("bytearray", 9)) << PIVariant(PIDateTime::current());
//	piForeachC (PIVariant v, vl)
//		piCout << v << v.value<PIString>();
//	PIByteArray ba; ba << PIString("500");
//	piCout << PIVariant::fromValue(ba, "PIString");
//	piCout << PIVariant("PIString");
//	piCout << __PIVariantFunctions__<int>::typeNameHelper();
//	piCout << __PIVariantInfoStorage__::get()->map->size();
//	for (PIMap<PIString, __PIVariantInfo__*>::iterator i = __PIVariantInfoStorage__::get()->map->begin(); i != __PIVariantInfoStorage__::get()->map->end(); ++i)
//		piCout << i.key() << i.value()->cast.size();
//	PIEthernet eth;
//	piCout << eth.properties();
//	MS ms = (MS){-1, 3.3, "str"};
//	PIVariant mv = PIVariant::fromValue<MS>(ms);
//	piCout << mv << mv.type();
//	piCout << mv.toInt();
//	piCout << mv.toFloat();
//	piCout << mv.toString();
//	piCout << ms << mv.value<MS>() << vl[0].value<MS>();
	/*PIScreen screen;
	TileSimple window;
	window.back_format.color_back = PIScreenTypes::Red;
	window.content << TileSimple::Row("label", PIScreenTypes::CellFormat(PIScreenTypes::Black, PIScreenTypes::Transparent));
	screen.rootTile()->addTile(&window);
	screen.enableExitCapture(PIKbdListener::F10);
	screen.start();
	screen.waitForFinish();*/
	return 0;
}

