/* Parser.h
 *
 * Interface definition for the Parser class, which handles reading courses
 * files.
 */

#ifndef PARSER_H_INCLUDED
#define PARSER_H_INCLUDED 1

#include "World.h"
#include <vector>
#include <string>

class Parser
{
private:

	/*
	 * Variables
	 */
	World* loadMe_; // so the world doesn't need to be passed around

	/* verbose - determines verbosity of the input parsing.
	 * 0 = No output
	 * 1 = Only extra commands are reported
	 * 2 = Report on everything
	 */
	static const int MAX_VERBOSE = 2;
	int verbose_;
	std::vector<Triangle*> curMesh_; // triangle mesh being read in


	/*
	 * Functions
	 */

	/* parse()
	 *
	 * Parses input stream and sets up the World accordingly
	 * (uses Z's standardized format)
	 * Returns non-zero on error
	 */
	int parse(std::istream&);

	/* parseExtra()
	 *
	 * Parses any additional commands beyond the specified format.
	 *
	 * Additional commands:
	 *
	 * ball x y z	- moves the ball to (x,y,z)
	 * vel x y z	- sets ball's velocity to (x,y,z)
	 * light on/off - turns on or off shading
	 */
	int parseExtra(std::istream&);

	/* meshCleanUp()
	 *
	 * Cleans up between meshes.
	 */
	void meshCleanUp();

public:
	Parser(void);
	~Parser(void);

	/* loadFile()
	 *
	 * Takes in the world that we wish to alter and stores it in loadMe.
	 * Asks the user via stdin/out which file we should load the world from.
	 * Other options include:
	 *     none   - Don't load a world
	 *     cin    - Take input from console instead of file
	 *     format - Display acceptable input file format
	 */
	void loadFile(World* pWorld);
	
	/* getFile()
	 * 
	 * Gets a file with the given filename. If it is successful,
	 * it calls parse(), otherwise it returns an error.
	 *
	 * If necessary, it sets up the world instead of loadFile().
	 */
	int getFile(const std::string& filename, World* pWorld);

	// Change/Report Verbosity
	void setVerbosity(int verbose);
	void cycleVerbosity();
	void reportVerbosity();
};

#endif // PARSER_H_INCLUDED