1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * Config_ValidatorReader.cpp
6 * Created on: Mar 20, 2015
10 #include <Config_ValidatorReader.h>
11 #include <Config_Keywords.h>
12 #include <Config_Common.h>
13 #include <Config_ValidatorMessage.h>
14 #include <Config_PropManager.h>
16 #include <Events_Loop.h>
17 #include <libxml/parser.h>
18 #include <libxml/tree.h>
26 Config_ValidatorReader::Config_ValidatorReader(const std::string& theXmlFileName)
27 : Config_XMLReader(theXmlFileName)
31 Config_ValidatorReader::~Config_ValidatorReader()
35 void Config_ValidatorReader::processNode(xmlNodePtr theNode)
37 if (isNode(theNode, NODE_VALIDATOR, NULL)) {
38 processValidator(theNode);
39 } else if (isNode(theNode, NODE_FEATURE, NULL)) {
40 storeAttribute(theNode, _ID);
41 } else if (isWidgetNode(theNode)) {
42 storeAttribute(theNode, _ID);
43 // Store widget name to restore it's id on validator/selector processing
44 myCurrentWidget = getNodeName(theNode);
46 //Process SOURCE nodes.
47 Config_XMLReader::processNode(theNode);
50 void Config_ValidatorReader::cleanup(xmlNodePtr theNode)
52 if (isNode(theNode, NODE_FEATURE, NULL)) {
53 cleanupAttribute(theNode, _ID);
54 } else if (isWidgetNode(theNode)) {
55 cleanupAttribute(NODE_XMLPARENT, _ID);
56 // Cleanup widget name when leave the widget node.
61 bool Config_ValidatorReader::processChildren(xmlNodePtr aNode)
66 void Config_ValidatorReader::processValidator(xmlNodePtr theNode)
68 Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
69 Events_Loop* aEvLoop = Events_Loop::loop();
70 std::shared_ptr<Config_ValidatorMessage>
71 aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
72 std::string aValidatorId;
73 std::list<std::string> aParameters;
74 getParametersInfo(theNode, aValidatorId, aParameters);
75 aMessage->setValidatorId(aValidatorId);
76 aMessage->setValidatorParameters(aParameters);
77 std::string aFeatureId = restoreAttribute(NODE_FEATURE, _ID);
78 aMessage->setFeatureId(aFeatureId);
79 // parent is attribute (widget)
80 if (!myCurrentWidget.empty()) {
81 std::string aParentId = restoreAttribute(myCurrentWidget.c_str(), _ID);
82 aMessage->setAttributeId(aParentId);
84 aEvLoop->send(aMessage);