/*
 * Copyright (c) 2009 Veselin Georgiev
 *
 * Cutting the bullshit:
 *  all sources here are free software; you can use them for everything you
 *  want. Just don't blame me if something goes wrong; if something happens
 *  (including, but not limited to:
 *     coredumps, formatted harddrives, ping timeouts, winamp sound skips,
 *     fried CPUs, sudden mother-in-law visits, fraglimits, viagra spam,
 *     barking dogs, earthquakes, frog rain, Windows Vista installations,
 *     anrieff playing the bass guitar, dangerous sporks, apocalypse,
 *     concrete donkey, or even Chuck Norris getting your butt kicked...
 *  ), then you know you have been warned. Four times.
 *
 * Btw, Chuck Norris now doesn't code neither Python, nor Ruby. He's hacking
 * with Makefiles.
 */
#include <vcclr.h>

#define MAXX 128
#define MAXY 128

class QueryServer;

class QueryEngine {
	int zeroscore;
	int num_queries, q_type1, q_type2, q_misses, q_submits;
	QueryServer *server;
	int cache[2][2], cc;
	gcroot<System::DateTime> mark;
public:
	int data[MAXX * MAXY];
	int w, h;
public:
	QueryEngine(System::DateTime m);
	~QueryEngine();
	void init(int &width, int &height);
	void query(int x1, int y1, int x2, int y2);
	void query(int x, int y);
	void cached_query(int x, int y);
	void flush_cache(void);
	void submit(int *xdata);
	bool have_all() const;
	double time(void);
	int get_queries(void) const { return num_queries; }
	void mark_selected(int x, int y);
};

extern QueryEngine q;
