solver  1.0
Private Member Functions | Private Attributes | Friends | List of all members
XmlReader Class Reference

Parser of XML datasets. More...

#include <XmlReader.h>

+ Collaboration diagram for XmlReader:

Private Member Functions

void readDatasetFromXmlFile ()
 It parses the XML dataset (specified in Settings::DATASET_FILE) and checks it against schema.
 
void processRootNode (const xmlpp::Node *rootNode)
 It parses all the dataset and stores the data to member variables. More...
 
void processInstanceNode (const xmlpp::Node *node)
 It parses the problem instance specified by the node. More...
 
RobotprocessRobotNode (const xmlpp::Node *robotNode)
 It parses the data related to the robot, and creates the instance of Robot class. More...
 
StaticActivityprocessStaticActivityNode (const xmlpp::Node *node, const std::vector< RobotPowerMode * > &robotModes)
 An instance of the static activity is created from the parsed data and power saving modes of the robot. More...
 
DynamicActivityprocessDynamicActivityNode (const xmlpp::Node *node)
 An instance of the dynamic activity is created from the parsed data. More...
 
InterRobotOperationprocessInterRobotOperationNode (const xmlpp::Node *interRobotOperationNode) const
 It creates a new inter-robot operation from parsed data. More...
 
std::pair< ActivityMode *, ActivityMode * > processCollisionPairNode (const xmlpp::Node *collisionPairNode) const
 It parses an element containing time disjunctive pair, and returns the pointers to colliding locations/movements. More...
 
const xmlpp::Element * castToElement (const xmlpp::Node *node) const
 The method casts xmlpp::Node to xmlpp::Element, and in case of success the result is returned, otherwise an exception is thrown. More...
 
std::string getAttribute (const xmlpp::Element *node, const std::string &attributeName, bool required=true) const
 It parses the value assigned to the specified attribute and returns it in the form of string. More...
 
std::string getTextFromElement (const xmlpp::Element *element, const std::string &childName, bool required=true) const
 It tries to extract the text from the child element, e.g. getTextFromElement(instanceElement, "name", false) returns the name of the instance or an empty string if the name is not specified. More...
 

Private Attributes

std::vector< RoboticLinemLines
 Vector of problem instances, i.e. robotic cells.
 
std::vector< PrecalculatedMappingmMapping
 Vector of precalculated mappings for fast access by a key.
 
std::string mDatasetName
 Name of the dataset.
 
std::string mDatasetDescription
 Description of the dataset.
 
std::map< uint32_t, Activity * > mAidToActivity
 A map mapping the activity identification to the pointer to the related activity.
 
std::map< uint32_t, Location * > mPointToLocation
 Unique mapping of coordinate identifications (called points) to the related location.
 
std::map< Movement *, std::pair< uint32_t, uint32_t > > mMovementToPoints
 It maps the movement to start and end coordinates of the movement.
 

Friends

class InstancesReader
 Only InstancesReader is allowed to use the data and methods of this class.
 

Detailed Description

Parser of XML datasets.

Instance of XmlReader class parses XML datasets with problem instances, and fills data structures connected with the robotic cell. During the reading some elemental checks are performed, however, more complex checking and post-processing is accomplished by InstancesReader class.

See also
RoboticLine, InstancesReader

Definition at line 45 of file XmlReader.h.

Member Function Documentation

const Element * XmlReader::castToElement ( const xmlpp::Node *  node) const
private

The method casts xmlpp::Node to xmlpp::Element, and in case of success the result is returned, otherwise an exception is thrown.

Parameters
nodeA node of a document tree.
Returns
A pointer to an element, i.e. '<x>...</x>'.

Definition at line 365 of file XmlReader.cpp.

string XmlReader::getAttribute ( const xmlpp::Element *  node,
const std::string &  attributeName,
bool  required = true 
) const
private

It parses the value assigned to the specified attribute and returns it in the form of string.

Parameters
nodeAn element from which the attribute is extracted.
attributeNameThe name of the attribute.
requiredSpecifies whether the attribute is mandatory.
Returns
String containing the attribute value, e.g. "hello" if element is '<x attr="hello"/>'.
Note
If the attribute is not mandatory and also not present, then an empty string is returned.

Definition at line 372 of file XmlReader.cpp.

string XmlReader::getTextFromElement ( const xmlpp::Element *  element,
const std::string &  childName,
bool  required = true 
) const
private

It tries to extract the text from the child element, e.g. getTextFromElement(instanceElement, "name", false) returns the name of the instance or an empty string if the name is not specified.

Parameters
elementAn element that may contain an inner element called childName.
childNameAn element containing the text.
requiredIndicates whether the child element is mandatory.
Returns
A text extracted from the child element or an empty string.
Note
If the child element is optional, then an empty string can be returned.

Definition at line 385 of file XmlReader.cpp.

pair< ActivityMode *, ActivityMode * > XmlReader::processCollisionPairNode ( const xmlpp::Node *  collisionPairNode) const
private

It parses an element containing time disjunctive pair, and returns the pointers to colliding locations/movements.

Parameters
collisionPairNodeThe node of a document tree corresponding to '<collision-pair>...</collision-pair>' elements.
Returns
A pair containing the parsed collision pair.

Definition at line 319 of file XmlReader.cpp.

DynamicActivity * XmlReader::processDynamicActivityNode ( const xmlpp::Node *  node)
private

An instance of the dynamic activity is created from the parsed data.

Parameters
nodeThe node of a document tree corresponding to '<dynamic-activity>...</dynamic-activity>' elements.
Returns
Pointer to a newly created dynamic activity.

Definition at line 185 of file XmlReader.cpp.

void XmlReader::processInstanceNode ( const xmlpp::Node *  node)
private

It parses the problem instance specified by the node.

Parameters
nodeThe node of a document tree corresponding to '<instance>...</instance>' elements.

Definition at line 64 of file XmlReader.cpp.

InterRobotOperation * XmlReader::processInterRobotOperationNode ( const xmlpp::Node *  interRobotOperationNode) const
private

It creates a new inter-robot operation from parsed data.

Parameters
interRobotOperationNodeThe node of a document tree corresponding to '<operation>...</operation>' elements.
Returns
Pointer to a newly created inter-robot operation.

Definition at line 257 of file XmlReader.cpp.

Robot * XmlReader::processRobotNode ( const xmlpp::Node *  robotNode)
private

It parses the data related to the robot, and creates the instance of Robot class.

Parameters
robotNodeThe node of a document tree corresponding to '<robot>...</robot>' elements.
Returns
Pointer to a newly created robot.

Definition at line 100 of file XmlReader.cpp.

void XmlReader::processRootNode ( const xmlpp::Node *  rootNode)
private

It parses all the dataset and stores the data to member variables.

Parameters
rootNodeThe node of a document tree corresponding to '<dataset>...</dataset>' elements.

Definition at line 53 of file XmlReader.cpp.

StaticActivity * XmlReader::processStaticActivityNode ( const xmlpp::Node *  node,
const std::vector< RobotPowerMode * > &  robotModes 
)
private

An instance of the static activity is created from the parsed data and power saving modes of the robot.

Parameters
nodeThe node of a document tree corresponding to '<static-activity>...</static-activity>' elements.
robotModesThe vector containing the power saving modes of the robot that performs the activity specified by the node.
Returns
Pointer to a newly created static activity.

Definition at line 134 of file XmlReader.cpp.


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