annotate.h 2.28 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 37 38 39 40 41 42
 */

/*
 * Base class for the annotater. 
 */

#ifdef WITH_XML

#ifndef __ANNOTATE_H

#define __ANNOTATE_H

#include <utility>
#include <string>
#include <list>
#include <map>

#include <xercesc/dom/DOM.hpp>

class annotate
{
43
 protected: 
44 45
  xercesc::DOMDocument* document;
  xercesc::DOMElement* physical_root;
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  xercesc::DOMElement* virtual_root;
  std::map<std::string, xercesc::DOMElement*> *physical_elements;
  
 public:
  // Annotates nodes and direct links in the rspec
  virtual void annotate_element(const char* v_name, const char* p_name) = 0;
  
  // Annotates intraswitch and interswitch links in the rspec
  virtual void annotate_element(const char* v_name, 
				std::list<const char*>* links) = 0;
  
  // Creates a hop from a switch till the next end point. 
  // Adds the hop to the vlink and returns the hop element that was created
  virtual xercesc::DOMElement* 
    create_component_hop (const xercesc::DOMElement* plink, 
			  xercesc::DOMElement* vlink, 
			  int endpoint_interface, 
			  const xercesc::DOMElement* prev_component_hop) = 0;
  
  // Finds the next link in the path returned by assign
  virtual xercesc::DOMElement* 
    find_next_link_in_path (xercesc::DOMElement *prev, 
			    std::list<const char*>* links) = 0;
  
  // Writes the annotated xml to disk
  void write_annotated_file(const char* filename);
72 73 74

  // Writes an XML element to a string
  std::string printXML (const xercesc::DOMElement* tag);
75 76 77 78 79
};

#endif // for __ANNOTATE_H

#endif // for WITH_XML