rspec_parser.h 2.56 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2010 University of Utah and the Flux Group.
 * All rights reserved.
 */

/*
 * Header for RSPEC parser files
 */

# ifdef WITH_XML

#ifndef __RSPEC_PARSER__
#define __RSPEC_PARSER__

#include <list>
#include <map>
18
#include <set>
19 20
#include <string>
#include <utility>
21
#include <vector>
22 23
#include <xercesc/dom/DOM.hpp>

24 25
#define RSPEC_TYPE_ADVT 0
#define RSPEC_TYPE_REQ 1
26 27 28 29

struct node_type 
{
	std::string typeName;
30
	int typeSlots;
31 32 33 34 35 36 37 38 39 40 41 42
	bool isStatic;
};

struct link_characteristics
{
	int bandwidth;
	int latency;
	double packetLoss;
};

struct link_interface
{
43 44 45 46 47 48 49 50 51 52
	std::string virtualNodeId;
	std::string virtualIfaceId;
	std::string physicalNodeId;
	std::string physicalIfaceId;
};

struct node_interface
{
	std::string componentId;
	std::string clientId;
53 54 55 56 57
};

class rspec_parser
{
	private:
58
			
59
	protected:
60 61 62 63 64
		int rspecType; 
		std::set< std::pair<std::string, std::string> >ifacesSeen;
		std::string getAttribute (const xercesc::DOMElement*, const std::string,
															bool&);
		bool hasAttribute (const xercesc::DOMElement*, const std::string);
65 66 67 68
		struct link_interface getIface (const xercesc::DOMElement*);
		
	public:
		
69 70
		rspec_parser () { }
		rspec_parser(int type) { this->rspecType = type; }
71 72
		
		// Common functions
73 74
		virtual std::string readPhysicalId (const xercesc::DOMElement*, bool&);
		virtual std::string readVirtualId (const xercesc::DOMElement*, bool&);
75 76 77
		virtual std::string readComponentManagerId (const xercesc::DOMElement*,
				                                    bool&);
		
78 79 80
		// Reads subnode tag
		virtual std::string readSubnodeOf (const xercesc::DOMElement*, bool&);
		
81
		// Functions for nodes
82 83
		virtual std::vector<std::string> readLocation(const xercesc::DOMElement*,
																									int&);
84 85 86 87 88
		virtual std::list<struct node_type> 
				readNodeTypes (const xercesc::DOMElement*, int&);
		
		// Functions for links
		virtual struct link_characteristics 
89 90 91 92 93 94 95
				readLinkCharacteristics (const xercesc::DOMElement*, 
																 int defaultBandwidth, 
								 								 int unlimitedBandwidth,
																 int&);
				
		virtual std::vector< struct link_interface >
				readLinkInterface (const xercesc::DOMElement*, int&);
96
		
97 98 99 100 101 102 103
		// Reads all the interfaces on a node
		// Returns the number of interfaces found. 
		// This only populates the internal data structures of the object.
		// Ideally, this ought to be done automatically, but in the current setup,
		// there doesn't seem to be a clean way of making it happen.
		virtual int readInterfacesOnNode (const xercesc::DOMElement*, bool&);
		virtual void dummyFun();
104 105 106 107 108 109
};


#endif

#endif