/** * @file * @author 2012-2015 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) * @copyright Simplified BSD * * @cond * This program is free software: you can redistribute it and/or modify * it under the terms of the FreeBSD license as published by the FreeBSD * project. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the FreeBSD license along with this * program. If not, see . * @endcond */ #ifndef INTERPRETERINFO_H_CED68EFF #define INTERPRETERINFO_H_CED68EFF #include #include "uscxml/plugins/IOProcessor.h" #include "uscxml/plugins/Invoker.h" #include #include namespace uscxml { class USCXML_API NameSpaceInfo { public: NameSpaceInfo() : nsContext(NULL) { init(std::map()); } NameSpaceInfo(const std::map& nsInfo) : nsContext(NULL) { init(nsInfo); } NameSpaceInfo(const NameSpaceInfo& other) : nsContext(NULL) { init(other.nsInfo); } virtual ~NameSpaceInfo() { if (nsContext) delete nsContext; } NameSpaceInfo& operator=( const NameSpaceInfo& other ) { init(other.nsInfo); return *this; } void setPrefix(Arabica::DOM::Element element) { if (nsURL.size() > 0) element.setPrefix(nsToPrefix[nsURL]); } void setPrefix(Arabica::DOM::Attr attribute) { if (nsURL.size() > 0) attribute.setPrefix(nsToPrefix[nsURL]); } std::string getXMLPrefixForNS(const std::string& ns) const { if (nsToPrefix.find(ns) != nsToPrefix.end() && nsToPrefix.at(ns).size()) return nsToPrefix.at(ns) + ":"; return ""; } const Arabica::XPath::StandardNamespaceContext* getNSContext() { return nsContext; } std::string nsURL; // ough to be "http://www.w3.org/2005/07/scxml" but maybe empty std::string xpathPrefix; // prefix mapped for xpath, "scxml" is _xmlNSPrefix is empty but _nsURL set std::string xmlNSPrefix; // the actual prefix for elements in the xml file std::map nsToPrefix; // prefixes for a given namespace std::map nsInfo; // all xmlns mappings private: Arabica::XPath::StandardNamespaceContext* nsContext; void init(const std::map& nsInfo); }; class USCXML_API InterpreterInfo { public: virtual NameSpaceInfo getNameSpaceInfo() const = 0; virtual const std::string& getName() = 0; virtual const std::string& getSessionId() = 0; virtual const std::map& getIOProcessors() = 0; virtual bool isInState(const std::string& stateId) = 0; virtual Arabica::DOM::Document getDocument() const = 0; virtual const std::map& getInvokers() = 0; }; } #endif /* end of include guard: INTERPRETERINFO_H_CED68EFF */