UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
GTXLReaderXerces Class Reference

This class imports GXL or GTXL XML files and converts them to Hypergraph and GTS objects respectively. More...

#include <GTXLReaderXerces.h>

Inheritance diagram for GTXLReaderXerces:
Inheritance graph
[legend]
Collaboration diagram for GTXLReaderXerces:
Collaboration graph
[legend]

Public Member Functions

 GTXLReaderXerces ()
 Creates a new GTXLReaderXerces object, which includes initialization of the Xerces framework. More...
 
virtual ~GTXLReaderXerces ()
 Destroys the GTXLReaderXerces object. More...
 
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. More...
 
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. More...
 
bool areWarningsShown ()
 Returns true, iff warnings will be logged when they occur. More...
 
void setWarningsShown (bool show)
 Sets whether warning will be logged when they occur. More...
 

Static Public Member Functions

static GTXLReadernewReader ()
 Use this method to generate a new GTXLReader object. More...
 
static unique_ptr< GTXLReadernewUniqueReader ()
 Use this method to generate a new GTXLReader object. More...
 

Protected Attributes

bool showWarnings
 Specifies whether warnings for ignored XML nodes and attributes should be displayed or not.
 

Private Types

typedef unordered_map< string,
unordered_set< IDType > > 
QuantMap
 Alias for a map, mapping every quantification name to the set of ID of which it consists.
 
typedef 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 (second element) and the right rule side (third element).
 

Private Member Functions

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 and right sides. More...
 
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. More...
 
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. More...
 
void readAnonHypergraph (xercesc::DOMElement *graphroot, unordered_map< IDType, IDType > *oldIDs, graphs::AnonHypergraph &graph, IDType const &graphID, unordered_map< string, IDType > &strToID) const
 This method serves as an implementation of both the readHypergraph(..,..) and the readAnonHypergraph(..) functions, filling all parameters given, with exception of the first, with data read from the given XML node. More...
 
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. More...
 
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. More...
 
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. More...
 
void checkConsistency (graphs::Rule const &rule, GTXLReaderXerces::QuantMap &leftQuantMap, GTXLReaderXerces::QuantMap &rightQuantMap) const
 Checks if a consistent UQRule can be generated from the given Rule and QuantMaps. More...
 
void checkConsistency (graphs::AnonHypergraph const &graph, GTXLReaderXerces::QuantMap const &quantMap) const
 Checks if the given partition of the given graph into quantifications is consistent. More...
 
bool isEqualIgnoringCase2 (const XMLCh *lowerCase, const XMLCh *notLowerCase) const
 Checks if the two strings are equal. More...
 

Private Attributes

XMLCh * xmlch_gxl
 
XMLCh * xmlch_edgeids
 
XMLCh * xmlch_true
 
XMLCh * xmlch_hypergraph
 
XMLCh * xmlch_text
 
XMLCh * xmlch_id
 
XMLCh * xmlch_rel
 
XMLCh * xmlch_relend
 
XMLCh * xmlch_target
 
XMLCh * xmlch_role
 
XMLCh * xmlch_startorder
 
XMLCh * xmlch_attr
 
XMLCh * xmlch_name
 
XMLCh * xmlch_string
 
XMLCh * xmlch_edgemode
 
XMLCh * xmlch_node
 
XMLCh * xmlch_edge
 
XMLCh * xmlch_label
 
XMLCh * xmlch_graph
 
XMLCh * xmlch_int
 
XMLCh * xmlch_gts
 
XMLCh * xmlch_initial
 
XMLCh * xmlch_rule
 
XMLCh * xmlch_lhs
 
XMLCh * xmlch_rhs
 
XMLCh * xmlch_rulegraph
 
XMLCh * xmlch_mapping
 
XMLCh * xmlch_mapelem
 
XMLCh * xmlch_from
 
XMLCh * xmlch_to
 
XMLCh * xmlch_type
 
XMLCh * xmlch_transformationunit
 
XMLCh * xmlch_quantification
 
XMLCh * xmlch_elem
 
XMLCh * xmlch_ref
 

Detailed Description

This class imports GXL or GTXL XML files and converts them to Hypergraph and GTS objects respectively.

Xerces is used as underlying Framework.

Author
Jan Stückrath
See Also
graphs::Hypergraph
graphs::GTS

Constructor & Destructor Documentation

Creates a new GTXLReaderXerces object, which includes initialization of the Xerces framework.

No additional initialization is needed.

~GTXLReaderXerces ( )
virtual

Destroys the GTXLReaderXerces object.

This also frees all resources reserved for Xerces.

Member Function Documentation

bool areWarningsShown ( )
inherited

Returns true, iff warnings will be logged when they occur.

Returns
true, iff warnings will be shown
void checkConsistency ( const graphs::Mapping match,
const graphs::Hypergraph left,
const graphs::Hypergraph right 
) const
private

Checks if the input parameters form a correct and consistent Rule.

Existence of mapped IDs is checked as well as the morphism property. An exception is thrown if the check is not successful.

Parameters
mappinga reference to the mapping to be checked
lefta pointer to the left graph of the Match
righta pointer to the right graph of the Match
Exceptions
XMLioExceptionif the given parameters form no correct Rule object
void checkConsistency ( graphs::Rule const &  rule,
GTXLReaderXerces::QuantMap leftQuantMap,
GTXLReaderXerces::QuantMap rightQuantMap 
) const
private

Checks if a consistent UQRule can be generated from the given Rule and QuantMaps.

An exception is thrown if the check is not successful.

Parameters
rulethe rule for which consistency should be checked
leftQuantMapa mapping of all quantifications to the IDs of which they consist in the left rule side
rightQuantMapa mapping of all quantifications to the IDs of which they consist in the right rule side
void checkConsistency ( graphs::AnonHypergraph const &  graph,
GTXLReaderXerces::QuantMap const &  quantMap 
) const
private

Checks if the given partition of the given graph into quantifications is consistent.

An exception is thrown if the check is not successful.

Parameters
graphthe graph to be checked
quantMapa mapping of all quantifications to the IDs of which they consist
void convertToQuant ( graphs::UQRule rule,
unordered_set< IDType > const &  leftQuant,
unordered_set< IDType > const &  rightQuant 
) const
private

Takes the given UQRule and generates a quantification consisting of all specified element in the left and right sides.

The elements with IDs specified by 'leftQuant' and 'rightQuant' are moved from the core rule of the given UQRule into a new quantification (deleting parts of the core rule). The mapping of the quantification is implicitly given by the core rule (and deleted from it in the process).

Parameters
rulethe UQRule for which the quantification should be generated
leftQuantthe set of IDs of which the left quantification side will consist
rightQuantthe set of IDs of which the right quantification side will consist
bool isEqualIgnoringCase2 ( const XMLCh *  lowerCase,
const XMLCh *  notLowerCase 
) const
inlineprivate

Checks if the two strings are equal.

The first string is assumed to be lower case, while upper case symbols of the second string will be treated as if they where lower case.

Parameters
lowerCasea string containing only lower case symbols
notLowerCasea string containing lower and/or upper case symbols
Returns
true, iff the strings are equal, ignoring cases of the second string
GTXLReader * newReader ( )
staticinherited

Use this method to generate a new GTXLReader object.

No initialization is needed before use.

Warning
The caller has to properly delete the GTXLReader after use to avoid memory leaks.
Returns
a pointer to a new GTXLReader object
unique_ptr< GTXLReader > newUniqueReader ( )
staticinherited

Use this method to generate a new GTXLReader object.

No initialization is needed before use.

Returns
a pointer to a new GTXLReader object
pair< AnonHypergraph_sp, unordered_map< string, IDType > > readAnonHypergraph ( xercesc::DOMElement *  graphroot) const
private

This method takes a DOMElement object and tries to extract an AnonHypergraph out of it.

The given DOMElement has to be the root element of a 'graph' node specified by the GXL definition. Additionally to a pointer to the extracted AnonHypergraph, a mapping of the IDs used in the XML file to the internal IDs of the Hypergraph, is returned.

Parameters
graphroota DOMElement object containing the root element of a 'graph'
Returns
a pointer to the extracted graph and a mapping of the XML IDs to the graph IDs
Exceptions
exceptions::XMLioExceptionif the given DOMElement is not a correct graph
void readAnonHypergraph ( xercesc::DOMElement *  graphroot,
unordered_map< IDType, IDType > *  oldIDs,
graphs::AnonHypergraph graph,
IDType const &  graphID,
unordered_map< string, IDType > &  strToID 
) const
private

This method serves as an implementation of both the readHypergraph(..,..) and the readAnonHypergraph(..) functions, filling all parameters given, with exception of the first, with data read from the given XML node.

The given DOMElement has to be the root element of a 'graph' node specified by the GXL definition. If the oldIDs parameter in not null, the old ID stored in the 'graph' XML node is read and the graphs new ID is mapped to it. The read graph is stored into the given graph parameter. The given graphID is only used if oldIDs is not null (as key in the mapping). In the strToID parameter all XML IDs of vertices and edges are mapped to their IDs in the read graph.

Parameters
graphroota DOMElement object containing the root element of a 'graph'
oldIDsif given, the read graphs new ID is mapped to the old (stored) ID
graphthe graph to which the read data is stored
graphIDthe ID of the given graph, if it is not an anonymous graph (ignored if oldIDs is null)
strToIDevery XML ID of a vertex or edge with be mapped by this map to their ID in the read graph
Exceptions
exceptions::XMLioExceptionif the given DOMElement is not a correct graph
GTS_sp readGTXL ( string  filename,
unordered_map< IDType, IDType > *  oldRuleIDs = nullptr,
unordered_map< IDType, IDType > *  oldGraphIDs = nullptr 
) const
overridevirtual

This method takes a path to a GTXL XML-file and reads the stored GTS.

Parameters
filenamea complete path to a GTXL file
oldRuleIDsif given, this map will be filled with pairs of rule IDs mapped to (old) IDs read from the input files
oldGraphIDsif given, this map will be filled with pairs of graph IDs mapped to (old) IDs read from the input files
Returns
a pointer to the read GTS
Exceptions
io::XMLioExceptionif the specified file is not found or erroneous

Implements GTXLReader.

shared_ptr< vector< Hypergraph_sp > > readGXL ( string  filename,
unordered_map< IDType, IDType > *  oldIDs 
) const
overridevirtual

This method takes a path to a GXL XML-file and reads all hypergraphs stored in it.

Parameters
filenamea complete path to a GXL file
oldIDsif given, this map will be filled with pairs of graph IDs mapped to (old) IDs read from the input files
Returns
a pointer to a vector of the graphs read
Exceptions
io::XMLioExceptionif the specified file is not found or erroneous

Implements GTXLReader.

pair< Hypergraph_sp, unordered_map< string, IDType > > readHypergraph ( xercesc::DOMElement *  graphroot,
unordered_map< IDType, IDType > *  oldIDs = nullptr 
) const
private

This method takes a DOMElement object and tries to extract a Hypergraph out of it.

The given DOMElement has to be the root element of a 'graph' node specified by the GXL definition. Additionally to a pointer to the extracted Hypergraph, a mapping of the IDs used in the XML file to the internal IDs of the Hypergraph, is returned.

Parameters
graphroota DOMElement object containing the root element of a 'graph'
oldIDsif given, the read graphs new ID is mapped to the old (stored) ID
Returns
a pointer to the extracted Hypergraph and a mapping of the XML IDs to the Hypergraph IDs
Exceptions
exceptions::XMLioExceptionif the given DOMElement is not a correct Hypergraph
void readQuantMap ( xercesc::DOMElement *  root,
GTXLReaderXerces::QuantMap quantMap,
unordered_map< string, IDType > &  idMap 
) const
private

Takes a 'quantification' XML element and extracts the QuantMap from it.

Parameters
rootthe 'quantification' XML element
quantMapthe QuantMap in which the read entries will be stored
idMapa mapping from the XML IDs to IDs of the graph on which the quantification is defined
tuple< Rule_sp, GTXLReaderXerces::QuantMap, GTXLReaderXerces::QuantMap > readRule ( xercesc::DOMElement *  ruleroot,
unordered_map< IDType, IDType > *  oldIDs = nullptr 
) const
private

This method takes a DOMElement object and tries to extract a Rule out of it.

The given DOMElement has to be the root element of a 'rule' node specified by the GTXL definition.

Parameters
ruleroota DOMElement object containing the root element of a 'rule'
oldIDsif given, the read rules new ID is mapped to the old (stored) ID
Returns
a pointer to the extracted Rule
Exceptions
exceptions::XMLioExceptionif the given DOMElement is not a correct Rule
void setWarningsShown ( bool  show)
inherited

Sets whether warning will be logged when they occur.

Parameters
showset to true, if warnings should be logged

The documentation for this class was generated from the following files: