Repository navigation
reading xml input
For reading xml input files XmlReader is used, although all the XmlReader really does is to lead to Xerces, which fills a ParamNode element with an XML file content using the DOM parser from the Xerces library. The Xerces library provides the ability to properly read and output XML files.
This requires an XML-schema which, for cfs is stored in share/xml/CFS-Simulation/CFS.xsd. The xsd file contains pointers for each existing filter which link to an specific xsd file, therefore unique filter names are generated which make a distinct assignment possible. The specific xsd file defines all the settings and parameters available for the filter. So one can summarize that Xerces knows from these specific xsd files which parameters are available for which filter.
Establishing a new filter means appending a new tag into the existing CFS.xsd or CFS_Dat.xsd and creating a whole new specific filter csd file. Changing an already existing filter can mean that the schema has to change as well, if the required parameter do not stay the same.
Workflow of adding a new parameter:
- Change schema of certain filter.
- Load parameter into CFS++ by using:
PtrParamNode New_param = loaded_xml->Get('New_param')
Loading xml-file in CFS++:
paramNode_ = XmlReader::ParseFile(xmlFile, schema);
In addition, a material xml file is required in which all material related parameters are stored. The XML-schema is stored in share/CFS-Material/CFS_Material.xsd. As for the general xml file the scheme only links to material specific schemes in which the actual material parameters are defined.
The material handler basically opens the XMLMaterialHandler.cc in which the actual material xml file gets loaded in a same way like the general xml file.
Loading the material-xml-file in CFS ++:
materialHandler = fileHandler.CreateMaterialHandler(rootNode );
To be able to access these parameters after loading them at least two possibilities exist:
- Creating a point to a single parameter:
PtrParamNode pipelineNode = configNode->Get("pipeline"); - Creating a pointer to a list over which looping is possible:
ParamNodeList filters = PipelineNode->GetChildren();(The length of the list can obtained with:filters.GetSize();)
If a special data type is required for an input parameter the following possibility exists:
-
globalFactor_ = configNode->Get("scheme")->Get("globalFactor")->As<Double>();It has to be checked if the parameter really exist before assigning it!
Another possibility to access a parameter for which the variable has to be defined before it gets assigned is:
std::string dampId;-
curRegNode->GetValue("dampingId",dampId);This Get() version overwrites with throwException=false a preset value and does nothing if the value does not exist, therefore checking if the parameter exists is not necessary.
Overall many different possibilities to access different parameters loaded from the xml schema exist, which can be seen in ParamNode.hh