001/* Causality interface where no output depends on any input. 002 003 Copyright (c) 2008-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.actor.util; 029 030import java.util.Collection; 031 032import ptolemy.actor.Actor; 033import ptolemy.actor.IOPort; 034 035/////////////////////////////////////////////////////////////////// 036//// BreakCausalityInterface 037 038/** 039 This class provides a causality interface 040 where no output port depends on any input port. 041 That is, the dependency of any output port on any 042 input port is the oPlusIdentity() of the specified 043 default dependency. 044 <p> 045 The {@link #equivalentPorts(IOPort)} normally returns list 046 containing only the specified port. If, however, the actor 047 has any instance of PortParameter in its input port list, then 048 it returns a list of all input ports. The reason for this is 049 that any output, present or future, may depend on the values at 050 such port parameters. In particular, it is necessary for inputs 051 on these port parameters to be present when any other input is 052 processed because it affects the parameters of the actor. 053 It is more efficient to use this 054 class than to use the base class and call removeDependency() 055 to remove all the dependencies. 056 057 @see Dependency 058 059 @author Edward A. Lee 060 @version $Id$ 061 @since Ptolemy II 8.0 062 @Pt.ProposedRating Yellow (eal) 063 @Pt.AcceptedRating Red (eal) 064 */ 065public class BreakCausalityInterface extends DefaultCausalityInterface { 066 067 /** Construct a causality interface for the specified actor. 068 * @param actor The actor for which this is a causality interface. 069 * @param defaultDependency The default dependency of an output 070 * port on an input port. 071 */ 072 public BreakCausalityInterface(Actor actor, Dependency defaultDependency) { 073 super(actor, defaultDependency); 074 } 075 076 /////////////////////////////////////////////////////////////////// 077 //// public methods //// 078 079 /** Return a collection of the ports in this actor that depend on 080 * or are depended on by the specified port. This method 081 * returns an empty collection. 082 * <p> 083 * Derived classes may override this, but they may need to 084 * also override {@link #getDependency(IOPort, IOPort)} 085 * and {@link #equivalentPorts(IOPort)} to be consistent. 086 * @param port The port to find the dependents of. 087 * @return a collection of ports, this method returns 088 * an empty collection of ports 089 */ 090 @Override 091 public Collection<IOPort> dependentPorts(IOPort port) { 092 return _EMPTY_COLLECTION; 093 } 094 095 /** Return the dependency between the specified input port 096 * and the specified output port. This method returns 097 * the oPlusIdentity() of the default dependency given 098 * in the constructor. 099 * <p> 100 * Derived classes should override this method to provide 101 * actor-specific dependency information. If they do so, 102 * then they may also need to override {@link #equivalentPorts(IOPort)} 103 * and {@link #dependentPorts(IOPort)} to be consistent. 104 * @param input The specified input port. 105 * @param output The specified output port. 106 * @return The dependency between the specified input port 107 * and the specified output port. 108 */ 109 @Override 110 public Dependency getDependency(IOPort input, IOPort output) { 111 return _defaultDependency.oPlusIdentity(); 112 } 113 114 /** Remove the dependency that the specified output port has 115 * on the specified input port. This method does nothing since 116 * in this class, all dependencies have already been removed. 117 * @see #getDependency(IOPort, IOPort) 118 * @param inputPort The input port. 119 * @param outputPort The output port that does not depend on the 120 * input port. 121 */ 122 @Override 123 public void removeDependency(IOPort inputPort, IOPort outputPort) { 124 } 125}