本文整理汇总了C++中NodeSet::to_document_order方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet::to_document_order方法的具体用法?C++ NodeSet::to_document_order怎么用?C++ NodeSet::to_document_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeSet
的用法示例。
在下文中一共展示了NodeSet::to_document_order方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ATTR
Arabica::XPath::NodeSet<std::string> InterpreterDraft6::selectEventlessTransitions() {
Arabica::XPath::NodeSet<std::string> enabledTransitions;
NodeSet<std::string> states;
for (unsigned int i = 0; i < _configuration.size(); i++) {
if (isAtomic(_configuration[i]))
states.push_back(_configuration[i]);
}
states.to_document_order();
#if 0
std::cout << "Atomic States: ";
for (int i = 0; i < atomicStates.size(); i++) {
std::cout << ATTR(atomicStates[i], "id") << ", ";
}
std::cout << std::endl;
#endif
unsigned int index = 0;
while(states.size() > index) {
bool foundTransition = false;
NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", states[index]);
for (unsigned int k = 0; k < transitions.size(); k++) {
if (!HAS_ATTR(transitions[k], "event") && hasConditionMatch(transitions[k])) {
enabledTransitions.push_back(transitions[k]);
foundTransition = true;
goto LOOP;
}
}
if (!foundTransition) {
Node<std::string> parent = states[index].getParentNode();
if (parent) {
states.push_back(parent);
}
}
LOOP:
index++;
}
#if 0
std::cout << "Enabled eventless transitions: " << std::endl;
for (int i = 0; i < enabledTransitions.size(); i++) {
std::cout << enabledTransitions[i] << std::endl << "----" << std::endl;
}
std::cout << std::endl;
#endif
enabledTransitions = filterPreempted(enabledTransitions);
return enabledTransitions;
}
示例2: sort
void sort(const DOMNode& node,
NodeSet& nodes,
ExecutionContext<string_type, string_adaptor>& context) const
{
if(!sort_)
{
if(!nodes.forward())
nodes.to_document_order();
return;
}
sort_->set_context(node, context);
std::stable_sort(nodes.begin(), nodes.end(), SortP(*sort_));
} // sort
示例3: getTargetStates
//.........这里部分代码省略.........
for (int j = 0; j < tStates.size(); j++) {
NodeSet<std::string> ancestors = getProperAncestors(tStates[j], ancestor);
#if VERBOSE
std::cout << _name << ": Proper Ancestors of " << ATTR(tStates[j], "id") << " and " << ATTR(ancestor, "id") << ": ";
for (int i = 0; i < ancestors.size(); i++) {
std::cout << ATTR(ancestors[i], "id") << ", ";
}
std::cout << std::endl;
#endif
for (int k = 0; k < ancestors.size(); k++) {
statesToEnter.push_back(ancestors[k]);
if(isParallel(ancestors[k])) {
NodeSet<std::string> childs = getChildStates(ancestors[k]);
for (int l = 0; l < childs.size(); l++) {
bool someIsDescendant = false;
for (int m = 0; m < statesToEnter.size(); m++) {
if (isDescendant(statesToEnter[m], childs[l])) {
someIsDescendant = true;
break;
}
}
if (!someIsDescendant) {
addStatesToEnter(childs[l], statesToEnter, statesForDefaultEntry);
}
}
}
}
}
}
}
statesToEnter.to_document_order();
#if VERBOSE
std::cout << _name << ": States to enter: ";
for (int i = 0; i < statesToEnter.size(); i++) {
std::cout << ATTR(statesToEnter[i], "id") << ", ";
}
std::cout << std::endl;
#endif
for (int i = 0; i < statesToEnter.size(); i++) {
Element<std::string> stateElem = (Element<std::string>)statesToEnter[i];
// extension for flattened interpreters
for (unsigned int k = 0; k < statesToEnter.size(); k++) {
NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToEnter[k]);
for (unsigned int j = 0; j < invokes.size(); j++) {
if (HAS_ATTR(invokes[j], "persist") && DOMUtils::attributeIsTrue(ATTR(invokes[j], "persist"))) {
invoke(invokes[j]);
}
}
}
// --- MONITOR: beforeEnteringState ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->beforeEnteringState(shared_from_this(), stateElem, (i + 1 < statesToEnter.size()));
}
USCXML_MONITOR_CATCH_BLOCK(beforeEnteringState)
}
// extension for flattened SCXML documents, we will need an explicit uninvoke element
NodeSet<std::string> uninvokes = filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", statesToEnter[i]);
示例4: getDocumentInitialTransitions
// process transitions until we are in a stable configuration again
void InterpreterDraft6::stabilize() {
monIter_t monIter;
NodeSet<std::string> enabledTransitions;
_stable = false;
if (_configuration.size() == 0) {
// goto initial configuration
NodeSet<std::string> initialTransitions = getDocumentInitialTransitions();
assert(initialTransitions.size() > 0);
enterStates(initialTransitions);
}
do { // process microsteps for enabled transitions until there are no more left
enabledTransitions = selectEventlessTransitions();
if (enabledTransitions.size() == 0) {
if (_internalQueue.size() == 0) {
_stable = true;
} else {
_currEvent = _internalQueue.front();
_internalQueue.pop_front();
#if VERBOSE
std::cout << "Received internal event " << _currEvent.name << std::endl;
#endif
// --- MONITOR: beforeProcessingEvent ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->beforeProcessingEvent(shared_from_this(), _currEvent);
}
USCXML_MONITOR_CATCH_BLOCK(beforeProcessingEvent)
}
if (_dataModel)
_dataModel.setEvent(_currEvent);
enabledTransitions = selectTransitions(_currEvent.name);
}
}
if (!enabledTransitions.empty()) {
// test 403b
enabledTransitions.to_document_order();
microstep(enabledTransitions);
}
} while(!_internalQueue.empty() || !_stable);
monIter = _monitors.begin();
// --- MONITOR: onStableConfiguration ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->onStableConfiguration(shared_from_this());
}
USCXML_MONITOR_CATCH_BLOCK(onStableConfiguration)
}
// when we reach a stable configuration, invoke
for (unsigned int i = 0; i < _statesToInvoke.size(); i++) {
NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _statesToInvoke[i]);
for (unsigned int j = 0; j < invokes.size(); j++) {
if (!HAS_ATTR(invokes[j], "persist") || !DOMUtils::attributeIsTrue(ATTR(invokes[j], "persist"))) {
invoke(invokes[j]);
}
}
}
_statesToInvoke = NodeSet<std::string>();
}
示例5: catch
// a macrostep
InterpreterState InterpreterDraft6::step(bool blocking) {
try {
monIter_t monIter;
NodeSet<std::string> enabledTransitions;
// setup document and interpreter
if (!_isInitialized)
init();
// if we failed return false
if (!_isInitialized)
return INIT_FAILED;
// run initial transitions
if (!_stable) {
stabilize();
// we might only need a single step
if (!_running)
goto EXIT_INTERPRETER;
return INITIALIZED;
}
if (!_running)
return FINISHED;
// read an external event and react
if (blocking) {
// wait until an event becomes available
while(_externalQueue.isEmpty()) {
_condVar.wait(_mutex);
}
} else {
// return immediately if external queue is empty
if (_externalQueue.isEmpty())
return NOTHING_TODO;
}
_currEvent = _externalQueue.pop();
#if VERBOSE
std::cout << "Received externalEvent event " << _currEvent.name << std::endl;
if (_running && _currEvent.name == "unblock.and.die") {
std::cout << "Still running " << this << std::endl;
} else {
std::cout << "Aborting " << this << std::endl;
}
#endif
_currEvent.eventType = Event::EXTERNAL; // make sure it is set to external
// when we were blocking on destructor invocation
if (!_running) {
goto EXIT_INTERPRETER;
return INTERRUPTED;
}
// --- MONITOR: beforeProcessingEvent ------------------------------
for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) {
try {
(*monIter)->beforeProcessingEvent(shared_from_this(), _currEvent);
}
USCXML_MONITOR_CATCH_BLOCK(beforeProcessingEvent)
}
if (iequals(_currEvent.name, "cancel.invoke." + _sessionId))
return INTERRUPTED;
try {
_dataModel.setEvent(_currEvent);
} catch (Event e) {
LOG(ERROR) << "Syntax error while setting external event:" << std::endl << e << std::endl << _currEvent;
}
for (std::map<std::string, Invoker>::iterator invokeIter = _invokers.begin();
invokeIter != _invokers.end();
invokeIter++) {
if (iequals(invokeIter->first, _currEvent.invokeid)) {
Arabica::XPath::NodeSet<std::string> finalizes = filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement());
for (int k = 0; k < finalizes.size(); k++) {
Element<std::string> finalizeElem = Element<std::string>(finalizes[k]);
executeContent(finalizeElem);
}
}
if (HAS_ATTR(invokeIter->second.getElement(), "autoforward") && DOMUtils::attributeIsTrue(ATTR(invokeIter->second.getElement(), "autoforward"))) {
try {
// do not autoforward to invokers that send to #_parent from the SCXML IO Processor!
// Yes do so, see test229!
// if (!boost::equals(_currEvent.getOriginType(), "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"))
invokeIter->second.send(_currEvent);
} catch(...) {
LOG(ERROR) << "Exception caught while sending event to invoker " << invokeIter->first;
}
}
}
// run internal processing until we reach a stable configuration again
enabledTransitions = selectTransitions(_currEvent.name);
if (!enabledTransitions.empty()) {
// test 403b
enabledTransitions.to_document_order();
//.........这里部分代码省略.........