emulab_extensions_parser.h 3.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2008, 2009 University of Utah and the Flux Group.
 * All rights reserved.
 */

#ifndef __EMULAB_EXTENSIONS_PARSER_H__
#define __EMULAB_EXTENSIONS_PARSER_H__

#ifdef WITH_XML

#include <string>
13
#include <vector>
14 15 16
#include <xercesc/dom/DOM.hpp>
#include "rspec_parser_helper.h"

17
namespace rspec_emulab_extension {
18

19 20 21 22 23 24
#define LOCAL_OPERATOR 0
#define GLOBAL_OPERATOR 1
#define NORMAL_OPERATOR 2
  
#define HARD_VCLASS 0
#define SOFT_VCLASS 1
25 26 27 28 29 30

  struct policy {
    std::string type;
    std::string name;
    std::string limit;
  };
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
  
  struct emulab_operator {
    std::string op;
    int type;
  };
  
  struct fd 
  {
    std::string fd_name;
    float fd_weight;
    bool violatable;
    struct emulab_operator op;
  };
  
  struct node_flags
  {
    int trivialBandwidth;
    std::string subnodeOf;
    bool unique;
    bool disallowTrivialMix;
  };
  
  struct link_flags
  {
    bool noDelay;
    bool multiplexOk;
    bool trivialOk;
    std::string fixSrcIface;
    std::string fixDstIface;
  };
  
  struct hardness {
    int type;
    float weight;	
  };
  
  struct vclass {
    std::string name;
    struct hardness type;
70
    std::vector<std::string> physicalTypes;
71 72 73 74 75 76 77 78 79
  };
  
  struct property {
    std::string name;
    std::string value;
    float penalty;
    bool violatable;
    struct emulab_operator op;
  };
80

81 82 83 84 85 86 87 88
  struct type_limit {
    std::string typeClass;
    int typeCount;
  };
  
  class emulab_extensions_parser : public rspec_parser_helper {
  private:
    int type;
89 90
    struct emulab_operator readOperator(const xercesc::DOMElement* tag);
    struct hardness readHardness (const xercesc::DOMElement* tag);
91 92 93 94 95 96
    
  public:
    // Constructor
    emulab_extensions_parser(int type) { this->type = type; }
    
    // Functions
97 98 99 100 101 102 103 104
    std::vector<struct fd> readFeaturesDesires (const xercesc::DOMElement*, 
						int&);
    struct fd readFeatureDesire (const xercesc::DOMElement* tag);
    struct node_flags readNodeFlag (const xercesc::DOMElement* tag);
    struct link_flags readLinkFlag (const xercesc::DOMElement* tag);
    std::vector<struct property> readProperties
      (const xercesc::DOMElement* elem);
    struct property readProperty (const xercesc::DOMElement* tag);
105
    std::vector<struct vclass> readVClasses (const xercesc::DOMElement*);
106 107 108 109 110
    struct vclass readVClass (const xercesc::DOMElement* tag);
    std::string readAssignedTo (const xercesc::DOMElement* tag);
    std::string readHintTo (const xercesc::DOMElement* tag);
    std::string readTypeSlots (const xercesc::DOMElement* tag);
    bool readStaticType (const xercesc::DOMElement* tag);
111
    std::vector<struct type_limit> readTypeLimits(const xercesc::DOMElement*,
112
						  int& count);
113 114 115 116 117 118 119
    std::string readSubnodeOf (const xercesc::DOMElement* tag, bool&);
    virtual bool readDisallowTrivialMix (const xercesc::DOMElement* tag);
    virtual bool readUnique (const xercesc::DOMElement* tag);
    virtual int readTrivialBandwidth (const xercesc::DOMElement* tag, bool&);
    virtual std::string readHintTo (const xercesc::DOMElement* tag, bool&);
    virtual bool readNoDelay (const xercesc::DOMElement* tag);
    virtual bool readTrivialOk (const xercesc::DOMElement* tag);
120 121 122 123 124 125
    virtual bool readMultiplexOk (const xercesc::DOMElement* tag);
    virtual string readFixedInterface (const xercesc::DOMElement*, bool&);
    virtual string readShortInterfaceName (const xercesc::DOMElement*, bool&);
    virtual struct policy readPolicy (const xercesc::DOMElement*);
    virtual std::vector<struct policy>
      readPolicies (const xercesc::DOMElement*, int& count);
126 127
  };
  
128
} // namespace rspec_emulab_extension
129 130 131 132

#endif // WITH_XML

#endif // __EMULAB_EXTENSIONS_PARSER_H__