Package ptolemy.actor.gt.data

Examples of ptolemy.actor.gt.data.MatchResult


        String ruleXMLFile = all ? args[1] : args[0];
        String hostXMLFile = all ? args[2] : args[1];

        MatchCallback matchCallback = new MatchCallback() {
            public boolean foundMatch(GraphMatcher matcher) {
                MatchResult match = matcher.getMatchResult();
                System.out.println("--- Match " + ++count + " ---");
                _printMatch(match);
                return !all;
            }
View Full Code Here


     *   otherwise.
     */
    public boolean match(Pattern pattern, CompositeEntity hostGraph) {

        // Matching result.
        _match = new MatchResult();

        // Temporary data structures.
        _lookbackList = new LookbackList();
        _temporaryMatch = new MatchResult();

        _success = _matchChildrenCompositeEntity(pattern, hostGraph);

        assert _lookbackList.isEmpty();
        assert _temporaryMatch.isEmpty();
View Full Code Here

                        boolean repeat = ((BooleanToken) repeatUntilFixpoint
                                .getToken()).booleanValue();
                        while (!_lastResults.isEmpty()) {
                            switch (mode) {
                            case REPLACE_FIRST:
                                MatchResult result = _lastResults.peek();
                                GraphTransformer.transform(this, result);
                                break;
                            case REPLACE_ANY:
                                result = _lastResults.get(_random
                                        .nextInt(_lastResults.size()));
                                GraphTransformer.transform(this, result);
                                break;
                            case REPLACE_ALL:
                                GraphTransformer.transform(this, _lastResults);
                                break;
                            }
                            if (!repeat) {
                                break;
                            }
                            _lastResults.clear();
                            matcher.match(getPattern(), _lastModel);
                        }
                    }

                    modelOutput.send(0, new ActorToken(_lastModel));
                    modified.send(0, BooleanToken.getInstance(foundMatch));
                    return;
                }
            }

            if (matchInput.getWidth() > 0 && matchInput.hasToken(0)
                    && _lastModel != null) {
                ObjectToken token = (ObjectToken) matchInput.get(0);
                MatchResult match = (MatchResult) token.getValue();
                if (match != null) {
                    CompositeEntity host = (CompositeEntity) match
                            .get(getPattern());
                    if (_lastModel != host && !_lastModel.deepContains(host)) {
                        throw new IllegalActionException(this,
                                "The match result cannot be used with the "
                                        + "current model.");
                    }
                    GraphTransformer.transform(this, match);
                    modelOutput.send(0, new ActorToken(_lastModel));
                }
            }

            if (trigger.getWidth() > 0 && trigger.hasToken(0)
                    && !_lastResults.isEmpty()) {
                trigger.get(0);
                _lastResultsOperation = LastResultsOperation.REMOVE_FIRST;
                MatchResult result = _lastResults.peek();
                matchOutput.send(0, new ObjectToken(result));
            }
        } catch (TransformationException e) {
            throw new IllegalActionException(this, e,
                    "Unable to transform model.");
View Full Code Here

            return;
        }

        GraphTransformer transformer = new GraphTransformer(transformationRule,
                matchResults);
        MatchResult matchResult = matchResults.get(0);
        NamedObj host = (NamedObj) matchResult.get(transformationRule
                .getPattern());
        if (host == null) {
            throw new TransformationException(
                    "Match result is invalid because "
                            + "it does not include the pattern.");
View Full Code Here

TOP

Related Classes of ptolemy.actor.gt.data.MatchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.