UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
GTXLReaderXerces.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef GTXLREADERXERCES_H_
21 #define GTXLREADERXERCES_H_
22 
23 #include "GTXLReader.h"
24 #include <xercesc/dom/DOMElement.hpp>
25 #include <tuple>
26 
27 namespace uncover {
28  namespace io {
29 
38 
39  public:
40 
46 
50  virtual ~GTXLReaderXerces();
51 
52  virtual shared_ptr<vector<graphs::Hypergraph_sp>> readGXL(string filename,
53  unordered_map<IDType,IDType>* oldIDs) const override;
54 
55  virtual graphs::GTS_sp readGTXL(string filename,
56  unordered_map<IDType,IDType>* oldRuleIDs = nullptr,
57  unordered_map<IDType,IDType>* oldGraphIDs = nullptr) const override;
58 
59  private:
60 
64  typedef unordered_map<string, unordered_set<IDType>> QuantMap;
65 
70  typedef std::tuple<graphs::Rule_sp, GTXLReaderXerces::QuantMap, GTXLReaderXerces::QuantMap> RuleTriple;
71 
81  void convertToQuant(graphs::UQRule& rule,
82  unordered_set<IDType> const& leftQuant,
83  unordered_set<IDType> const& rightQuant) const;
84 
94  pair<graphs::Hypergraph_sp,unordered_map<string, IDType>> readHypergraph(xercesc::DOMElement* graphroot,
95  unordered_map<IDType,IDType>* oldIDs = nullptr) const;
96 
105  pair<graphs::AnonHypergraph_sp,unordered_map<string, IDType>> readAnonHypergraph(xercesc::DOMElement* graphroot) const;
106 
122  void readAnonHypergraph(xercesc::DOMElement* graphroot,
123  unordered_map<IDType,IDType>* oldIDs,
124  graphs::AnonHypergraph& graph,
125  IDType const& graphID,
126  unordered_map<string,IDType>& strToID) const;
127 
136  GTXLReaderXerces::RuleTriple readRule(xercesc::DOMElement* ruleroot,
137  unordered_map<IDType,IDType>* oldIDs = nullptr) const;
138 
145  void readQuantMap(xercesc::DOMElement* root,
146  GTXLReaderXerces::QuantMap& quantMap,
147  unordered_map<string,IDType>& idMap) const;
148 
157  void checkConsistency(const graphs::Mapping& match,
158  const graphs::Hypergraph& left,
159  const graphs::Hypergraph& right) const;
160 
168  void checkConsistency(graphs::Rule const& rule,
169  GTXLReaderXerces::QuantMap& leftQuantMap,
170  GTXLReaderXerces::QuantMap& rightQuantMap) const;
171 
178  void checkConsistency(graphs::AnonHypergraph const& graph, GTXLReaderXerces::QuantMap const& quantMap) const;
179 
187  inline bool isEqualIgnoringCase2(const XMLCh* lowerCase, const XMLCh* notLowerCase) const;
188 
190  // This XML strings will be pre-transcoded and later used in the GXL and GTXL imports.
192  XMLCh* xmlch_gxl;
193  XMLCh* xmlch_edgeids;
194  XMLCh* xmlch_true;
195  XMLCh* xmlch_hypergraph;
196  XMLCh* xmlch_text;
197  XMLCh* xmlch_id;
198  XMLCh* xmlch_rel;
199  XMLCh* xmlch_relend;
200  XMLCh* xmlch_target;
201  XMLCh* xmlch_role;
202  XMLCh* xmlch_startorder;
203  XMLCh* xmlch_attr;
204  XMLCh* xmlch_name;
205  XMLCh* xmlch_string;
206  XMLCh* xmlch_edgemode;
207  XMLCh* xmlch_node;
208  XMLCh* xmlch_edge;
209  XMLCh* xmlch_label;
210  XMLCh* xmlch_graph;
211  XMLCh* xmlch_int;
212 
214  // This XML strings will be pre-transcoded and later used in the GTXL imports.
216  XMLCh* xmlch_gts;
217  XMLCh* xmlch_initial;
218  XMLCh* xmlch_rule;
219  XMLCh* xmlch_lhs;
220  XMLCh* xmlch_rhs;
221  XMLCh* xmlch_rulegraph;
222  XMLCh* xmlch_mapping;
223  XMLCh* xmlch_mapelem;
224  XMLCh* xmlch_from;
225  XMLCh* xmlch_to;
226  XMLCh* xmlch_type;
227  XMLCh* xmlch_transformationunit;
228  XMLCh* xmlch_quantification;
229  XMLCh* xmlch_elem;
230  XMLCh* xmlch_ref;
231 
232  };
233 
234  } /* namespace io */
235 } /* namespace uncover */
236 #endif
void checkConsistency(const graphs::Mapping &match, const graphs::Hypergraph &left, const graphs::Hypergraph &right) const
Checks if the input parameters form a correct and consistent Rule.
Definition: GTXLReaderXerces.cpp:858
void readQuantMap(xercesc::DOMElement *root, GTXLReaderXerces::QuantMap &quantMap, unordered_map< string, IDType > &idMap) const
Takes a 'quantification' XML element and extracts the QuantMap from it.
Definition: GTXLReaderXerces.cpp:817
Represents the data structure for a rule including a unique identifier.
Definition: Rule.h:38
This is the data structure representing a morphism mapping from a graph to another graph...
Definition: Mapping.h:36
This class imports GXL or GTXL XML files and converts them to Hypergraph and GTS objects respectively...
Definition: GTXLReader.h:34
GTXLReaderXerces()
Creates a new GTXLReaderXerces object, which includes initialization of the Xerces framework...
Definition: GTXLReaderXerces.cpp:41
bool isEqualIgnoringCase2(const XMLCh *lowerCase, const XMLCh *notLowerCase) const
Checks if the two strings are equal.
Definition: GTXLReaderXerces.cpp:993
unordered_map< string, unordered_set< IDType > > QuantMap
Alias for a map, mapping every quantification name to the set of ID of which it consists.
Definition: GTXLReaderXerces.h:64
pair< graphs::Hypergraph_sp, unordered_map< string, IDType > > readHypergraph(xercesc::DOMElement *graphroot, unordered_map< IDType, IDType > *oldIDs=nullptr) const
This method takes a DOMElement object and tries to extract a Hypergraph out of it.
Definition: GTXLReaderXerces.cpp:482
A Hypergraph represents a graph with a unique identifier.
Definition: Hypergraph.h:35
pair< graphs::AnonHypergraph_sp, unordered_map< string, IDType > > readAnonHypergraph(xercesc::DOMElement *graphroot) const
This method takes a DOMElement object and tries to extract an AnonHypergraph out of it...
Definition: GTXLReaderXerces.cpp:174
This class imports GXL or GTXL XML files and converts them to Hypergraph and GTS objects respectively...
Definition: GTXLReaderXerces.h:37
An AnonHypergraph is a data structure storing a hypergraph.
Definition: AnonHypergraph.h:43
virtual shared_ptr< vector< graphs::Hypergraph_sp > > readGXL(string filename, unordered_map< IDType, IDType > *oldIDs) const override
This method takes a path to a GXL XML-file and reads all hypergraphs stored in it.
Definition: GTXLReaderXerces.cpp:137
virtual ~GTXLReaderXerces()
Destroys the GTXLReaderXerces object.
Definition: GTXLReaderXerces.cpp:88
std::tuple< graphs::Rule_sp, GTXLReaderXerces::QuantMap, GTXLReaderXerces::QuantMap > RuleTriple
Alias for a triple consisting of a rule (first element) and two QuantMaps for the left rule side (sec...
Definition: GTXLReaderXerces.h:70
void convertToQuant(graphs::UQRule &rule, unordered_set< IDType > const &leftQuant, unordered_set< IDType > const &rightQuant) const
Takes the given UQRule and generates a quantification consisting of all specified element in the left...
Definition: GTXLReaderXerces.cpp:579
virtual graphs::GTS_sp readGTXL(string filename, unordered_map< IDType, IDType > *oldRuleIDs=nullptr, unordered_map< IDType, IDType > *oldGraphIDs=nullptr) const override
This method takes a path to a GTXL XML-file and reads the stored GTS.
Definition: GTXLReaderXerces.cpp:489
This class serves as data structure of a universally quantified rule.
Definition: UQRule.h:38
GTXLReaderXerces::RuleTriple readRule(xercesc::DOMElement *ruleroot, unordered_map< IDType, IDType > *oldIDs=nullptr) const
This method takes a DOMElement object and tries to extract a Rule out of it.
Definition: GTXLReaderXerces.cpp:696
unsigned int IDType
IDType is an (unsigned) integer specifically used as an Identifier of graphs, elements of graphs or a...
Definition: globals.h:53
shared_ptr< GTS > GTS_sp
Alias for a shared pointer to a GTS object.
Definition: GTS.h:164