Esempio n. 1
0
bool Breakpoint::matches(Interpreter interpreter, const Breakpoint& other) const {
	// would we match the given breakpoint?

	if (subject != UNDEF_SUBJECT &&
			other.subject != subject)
		return false; // subject does not match
	
	if (when != UNDEF_WHEN &&
			other.when != when)
		return false; // time does not match
	
	if (action != UNDEF_ACTION &&
			other.action != action)
		return false; // action does not match

	// when we have a qualifier it has to match
	if(invokeId.length() > 0 && invokeId != other.invokeId) {
		return false;
	}

	if(invokeType.length() > 0 && invokeType != other.invokeType) {
		return false;
	}

	if(stateId.length() > 0 && stateId != other.stateId) {
		return false;
	}

	if(eventName.length() > 0 && !InterpreterImpl::nameMatch(eventName, other.eventName)) {
		return false;
	}

	if(executableName.length() > 0 && executableName != other.executableName) {
		return false;
	}

	if(executableXPath.length()) {
		Arabica::XPath::NodeSet<std::string> nodes;
		try {
			nodes = interpreter.getNodeSetForXPath(executableXPath);
		} catch (...) {
			return false;
		}
		return Interpreter::isMember(other.element, nodes);
	}

	if(transSourceId.length() > 0 && transSourceId != other.transSourceId) {
		return false;
	}

	if(transTargetId.length() > 0 && transTargetId != other.transTargetId) {
		return false;
	}
	
	if (condition.length() > 0) {
		try {
			DataModel dm = interpreter.getDataModel();
			if (!dm || !dm.evalAsBool(condition)) {
				return false;
			}
		} catch (...) {
			return false;
		}
	}

	return true;
}