//============================================================================
// Name        : NetworkParser.h
// Author      : Alessandro Pinto <apinto@eecs.berkeley.edu>
//               University of California, Berkeley
//               545 Cory Hall, Berkeley, CA 94720
// Version     : $Id: NetworkParser.h,v 1.2 2007/12/13 03:25:27 apinto Exp $
// Copyright   : See COPYING file that comes with this distribution
// Description : Network parser interface.
//============================================================================

#ifndef NETWORKPARSER_H_
#define NETWORKPARSER_H_

#include <string>
#include <sstream>
#include <map>
#include <list>
#include "IdGraph.h"
#include "Factory.h"
#include "tinyxml.h"

namespace cosi {

/** This class defines a generic parser for networks.
 *
 *
 *@author Alessandro Pinto,
 *@author The Donald O. Pederson Center for Electronic System Design
 *@author Electrical Engineering Department
 *@author University of California, Berkeley
 *@author 545P Cory Hall, Berkeley, CA 94720
 *@author +1 (510) 642 9670
 *@author http://www.eecs.berkeley.edu/~apinto
 *
 *@version $Id: NetworkParser.h,v 1.2 2007/12/13 03:25:27 apinto Exp $
 */

class NetworkParser {
public:
	NetworkParser(string pFileName);
	virtual ~NetworkParser();
	void Parse();
	void Parse(TiXmlNode* pParent);
	IdGraph* GetNetwork();

private:
	void ParseDocument(TiXmlNode* pParent);

	// <Network>
	void ParseNetwork(TiXmlNode* pParent);
	void GetNetworkAttributes(TiXmlNode* pParent);

	// <Node>
	void ParseNode(TiXmlNode* pParent);
	void GetNodeAttributes(TiXmlNode* pParent);

	// <Link>
	void ParseLink(TiXmlNode* pParent);
	void GetLinkAttributes(TiXmlNode* pParent);

	// <NodeLabel>
	void ParseNodeLabel(TiXmlNode* pParent);
	void GetNodeLabelAttributes(TiXmlNode* pParent);

	// <NodeLabel>
    void ParseNodeMapLabel(TiXmlNode* pParent);
	//void GetNodeMapLabelAttributes(TiXmlNode* pParent);

	void ParseLinkMapLabel(TiXmlNode* pParent);

	// <Entry> node
	void ParseNodeMapEntry(TiXmlNode* pParent);
	void GetNodeMapEntryAttributes(TiXmlNode* pParent);

	// <LinkLabel>
	void ParseLinkLabel(TiXmlNode* pParent);
	void GetLinkLabelAttributes(TiXmlNode* pParent);

	// <Entry> link
	void ParseLinkMapEntry(TiXmlNode* pParent);
	void GetLinkMapEntryAttributes(TiXmlNode* pParent);

	Factory* mF;
	string mFileName;
	string mNetworkType ;
	string mNetworkName ;

	string mLabelName ;
	string mLabelFormat ;
	stringstream mLabelType ;
	list<string> mTypes ;

	//Temporary storage
	map<string,Vertex> mNodes ;
	map<string,Edge> mLinks ;
};

}

#endif /*NETWORKPARSER_H_*/
