diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-30 20:41:50 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-30 20:41:50 (GMT) |
commit | b7a2d38bdcee3bf85a32dea7ac74b144d5ef40fa (patch) | |
tree | bade629bcca6b6a1417cb45be4349a3c27ea0feb /src/uscxml/transform/FlatStateIdentifier.h | |
parent | afbd0c4463c6f28ec1cd6ea45a68fdbcfcfeae6c (diff) | |
download | uscxml-b7a2d38bdcee3bf85a32dea7ac74b144d5ef40fa.zip uscxml-b7a2d38bdcee3bf85a32dea7ac74b144d5ef40fa.tar.gz uscxml-b7a2d38bdcee3bf85a32dea7ac74b144d5ef40fa.tar.bz2 |
See detailled log
- Forcing Data.Type for Data(String) constructor now, default used to be INTERPRETED.
- setDataModel and addIOProcessor on interpreter now
- fixed a bug with Data(bool) constructor
- various smaller fixes
Diffstat (limited to 'src/uscxml/transform/FlatStateIdentifier.h')
-rw-r--r-- | src/uscxml/transform/FlatStateIdentifier.h | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/src/uscxml/transform/FlatStateIdentifier.h b/src/uscxml/transform/FlatStateIdentifier.h new file mode 100644 index 0000000..2ee0443 --- /dev/null +++ b/src/uscxml/transform/FlatStateIdentifier.h @@ -0,0 +1,155 @@ +/** + * @file + * @author 2012-2014 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 <http://www.opensource.org/licenses/bsd-license>. + * @endcond + */ + +#ifndef FLATSTATEIDENTIFIER_H_E9534AF9 +#define FLATSTATEIDENTIFIER_H_E9534AF9 + + +#include <sstream> +#include <string> +#include <list> +#include <map> + +namespace uscxml { + +class USCXML_API FlatStateIdentifier { +public: + FlatStateIdentifier(const std::string& identifier) { + std::string parsedName; + // parse unique state identifier + std::stringstream elemNameSS(identifier); + std::string section; + while(std::getline(elemNameSS, section, ';')) { + if (boost::starts_with(section, "active-")) { + std::stringstream stateSS(section.substr(7)); + std::string state; + while(std::getline(stateSS, state, '-')) { + if (state.length() > 0) { + active.push_back(state); + } + } + } else if (boost::starts_with(section, "entered-")) { + std::stringstream stateSS(section.substr(8)); + std::string state; + while(std::getline(stateSS, state, '-')) { + if (state.length() > 0) { + visited.push_back(state); + } + } + } else if (boost::starts_with(section, "history-")) { + std::stringstream stateSS(section.substr(8)); + std::string state; + std::string history; + while(std::getline(stateSS, state, '-')) { + if (state.length() > 0) { + if (history.size() == 0) { + history = state; + } else { + histories[history].push_back(state); + } + } else { + history = ""; + } + } + } + } + } + + std::string activeId() { + std::stringstream activeSS; + activeSS << "active-"; + for (std::list<std::string>::const_iterator activeIter = active.begin(); activeIter != active.end(); activeIter++) { + activeSS << *activeIter << "-"; + } + return activeSS.str(); + } + + std::list<std::string> active; + std::list<std::string> visited; + std::map<std::string, std::list<std::string> > histories; + + static std::string toHTMLLabel(const std::string& identifier, int minRows = 0) { + FlatStateIdentifier flatId(identifier); + + std::list<std::string>::const_iterator listIter; + std::stringstream labelSS; + std::string seperator; + +// labelSS << "<table valign=\"top\" align=\"left\" cellborder=\"0\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">"; +// labelSS << "<tr>"; +// labelSS << "<td balign=\"left\" align=\"left\" valign=\"top\">"; + + labelSS << "<b>active: </b>"; + labelSS << "{"; + for (listIter = flatId.active.begin(); listIter != flatId.active.end(); listIter++) { + labelSS << seperator << *listIter; + seperator = ", "; + } + labelSS << "}"; + + if (flatId.visited.size() > 0) { + minRows--; + + labelSS << "<br /><b>init: </b>"; + + labelSS << "{"; + seperator = ""; + for (listIter = flatId.visited.begin(); listIter != flatId.visited.end(); listIter++) { + labelSS << seperator << *listIter; + seperator = ", "; + } + labelSS << "}"; + } + +#if 1 + if (flatId.histories.size() > 0) { + minRows--; + + seperator = ""; + std::string histSeperator = "<br /> "; + + labelSS << "<br /><b>history: </b>"; + + std::map<std::string, std::list<std::string> >::const_iterator histIter; + for (histIter = flatId.histories.begin(); histIter != flatId.histories.end(); histIter++) { + labelSS << histSeperator << histIter->first << ": {"; + + for (listIter = histIter->second.begin(); listIter != histIter->second.end(); listIter++) { + labelSS << seperator << *listIter; + seperator = ", "; + } + labelSS << "}"; + seperator = ""; + } + } +#endif +// while(minRows-- > 0) +// labelSS << "<tr><td valign=\"top\"></td></tr>"; // eat up rest of space +// +// labelSS << "</td>"; +// labelSS << "</tr>"; +// labelSS << "</table>"; + return labelSS.str(); + } + +}; + +} + +#endif /* end of include guard: FLATSTATEIDENTIFIER_H_E9534AF9 */ |