Package ptolemy.data

Examples of ptolemy.data.ActorToken$ActorType


            if (modelName.getWidth() > 0 && modelName.hasToken(0)) {
                String name = ((StringToken) modelName.get(0)).stringValue();
                entity.setName(name);
            }

            model.send(0, new ActorToken(entity));
        } catch (Exception e) {
            throw new IllegalActionException(this, "Unable to parse moml.");
        }
    }
View Full Code Here


                    ((PortParameter) parameterObject).update();
                }
            }

            if (modelInput.hasToken(0)) {
                ActorToken token = (ActorToken) modelInput.get(0);
                _lastModel = (CompositeEntity) token.getEntity();
                _lastModel.setDeferringChangeRequests(false);

                Mode mode = _getMode();

                GraphMatcher matcher = new GraphMatcher();
                matcher.setMatchCallback(this);

                _collectAllMatches = mode != Mode.REPLACE_FIRST;
                _lastResults.clear();
                matcher.match(getPattern(), _lastModel);

                if (mode == Mode.REPLACE_FIRST || mode == Mode.REPLACE_ANY
                        || mode == Mode.REPLACE_ALL) {
                    boolean foundMatch = !_lastResults.isEmpty();
                    if (foundMatch) {
                        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()) {
View Full Code Here

TOP

Related Classes of ptolemy.data.ActorToken$ActorType

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.