annotate_rspec.h 4.2 KB
Newer Older
1
/*
Robert Ricci's avatar
Robert Ricci committed
2
 * Copyright (c) 2008-2010 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 */

/*
 * Base class for the annotater. 
 */

#ifdef WITH_XML

#ifndef __ANNOTATE_RSPEC_H
#define __ANNOTATE_RSPEC_H

#include "annotate.h"

#include <list>
#include <map>
37
#include <set>
38 39 40 41 42 43 44
#include <utility>
#include <string>

#include <xercesc/dom/DOM.hpp>

class annotate_rspec : public annotate
{
45 46 47 48 49 50 51 52 53 54 55
 private:
  // Enumeration of which interface in a hop 
  // is an interface to a link end point
  enum endpoint_interface_enum { NEITHER, SOURCE, DESTINATION, BOTH };
  std::map< std::string, std::set<std::string> > lan_links_map;
  
 public:
  annotate_rspec ();
  ~annotate_rspec () { ; }
  
  // Annotates nodes and direct links in the rspec
56
  virtual void annotate_element(const char* v_name, const char* p_name);
57 58
  
  // Annotates intraswitch and interswitch links in the rspec
59 60
  virtual void annotate_element(const char* v_name, 
				std::list<const char*>* links);
61 62
  
  // Annotate a trivial link
63
  virtual void annotate_element(const char* v_name);
64 65
  
  // Annotates an interface element on a link
66 67 68 69
  virtual void annotate_interface (const xercesc::DOMElement* plink, 
				   const xercesc::DOMElement* vlink, 
				   int interface_number,
				   bool is_trivial_link);
70 71
  
  // Annotates an interface element on a non-trivial link
72 73 74
  virtual void annotate_interface (const xercesc::DOMElement* plink, 
				   const xercesc::DOMElement* vlink, 
				   int interface_number);
75 76
  
  // Annotates an interface element on a trivial link
77 78
  virtual void annotate_interface (const xercesc::DOMElement* vlink,
				   int interface_number);
79 80 81 82
  
  // Creates a hop from a switch till the next end point. 
  // Adds the hop to the vlink
  // Returns the hop element that was created
83
  virtual xercesc::DOMElement* 
84 85 86 87 88 89 90 91
    create_component_hop (const xercesc::DOMElement* plink, 
			  xercesc::DOMElement* vlink, 
			  int endpoint_interface, 
			  const xercesc::DOMElement* prev_hop);
  
  // Creates a component_hop for a trivial link
  // Adds the hop to the vlink
  // Returns the hop element that was created
92
  virtual xercesc::DOMElement* create_component_hop (xercesc::DOMElement* vlink);
93 94 95
  
  // If the interface is the end point of a link/path, 
  // add two additional attributes to it
96 97 98
  virtual void set_interface_as_link_endpoint (xercesc::DOMElement* interface, 
					       const char* virtual_node_id, 
					       const char* virtual_interface_id);
99 100
  
  // Finds the next link in the path returned by assign
101
  virtual xercesc::DOMElement* find_next_link_in_path 
102 103 104 105
    (xercesc::DOMElement *prev, 
     std::list<const char*>* links);
  
  // Copies the component spec from the source to the destination
106 107
  virtual void copy_component_spec(const xercesc::DOMElement* src, 
				   xercesc::DOMElement* dst);
108 109 110
  
  // Copies the component hop from the auto-generated link 
  // to the requested link
111 112
  virtual void copy_component_hop(xercesc::DOMElement* requested_link, 
				  xercesc::DOMElement* component_hop);
113 114 115
  
  // Checks if the link contains an interface with 
  // virtual_interface_id = id
116
  virtual bool has_interface_with_id (std::string link_id, std::string id);
117 118
  
  // Removes all extra tags and generated elements from the XML document
119
  virtual void cleanup ();
120 121 122
  
  // Checks whether an element of type tag 
  // with attr_name = attr_value is a generated element
123 124 125
  virtual bool is_generated_element (const char* tag, 
				     const char* attr_name, 
				     const char* attr_value);
126 127 128
};

#endif //for __ANNOTATE_RSPEC_H
129

130
#endif // for WITH_XML