001/* An instance of DependencyDeclaration is an attribute that declares
002 dependencies between parameters.
003
004 Copyright (c) 2003-2013 The Regents of the University of California.
005 All rights reserved.
006 Permission is hereby granted, without written agreement and without
007 license or royalty fees, to use, copy, modify, and distribute this
008 software and its documentation for any purpose, provided that the above
009 copyright notice and the following two paragraphs appear in all copies
010 of this software.
011
012 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
013 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
014 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
015 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
016 SUCH DAMAGE.
017
018 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
019 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
020 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
021 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
022 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
023 ENHANCEMENTS, OR MODIFICATIONS.
024
025 PT_COPYRIGHT_VERSION_2
026 COPYRIGHTENDKEY
027
028 */
029package ptolemy.actor.util;
030
031import java.util.List;
032
033import ptolemy.data.expr.Variable;
034import ptolemy.kernel.util.Attribute;
035import ptolemy.kernel.util.IllegalActionException;
036import ptolemy.kernel.util.NameDuplicationException;
037
038///////////////////////////////////////////////////////////////////
039//// DependencyDeclaration
040
041/**
042 An instance of DependencyDeclaration is an attribute that declares
043 variable dependence information of a parameter.  This attribute is
044 usually created in a parameter, when necessary, during the
045 preinitialize method of an actor.  This class is used primarily by the
046 ConstVariableModelAnalysis class to determine a change context for
047 parameters whose value dependence is not declared through an
048 expression reference, but maintained by the actor's Java code instead.
049
050 <p> This attribute is not persistent by default, so it will not be exported
051 into a MoML representation of the model.
052
053 @author Steve Neuendorffer
054 @version $Id$
055 @since Ptolemy II 4.0
056 @Pt.ProposedRating Yellow (neuendor)
057 @Pt.AcceptedRating Yellow (neuendor)
058 @see ptolemy.actor.util.ConstVariableModelAnalysis
059 */
060public class DependencyDeclaration extends Attribute {
061    /** Construct an DependencyDeclaration attribute in the given
062     *  container with the given name. The container argument must not
063     *  be null, or a NullPointerException will be thrown.  If the
064     *  name argument is null, then the name is set to the empty
065     *  string. Increment the version number of the workspace.
066     *  Set this attribute to be not persistent.
067     *
068     *  @param container The container.
069     *  @param name The name of this attribute.
070     *  @exception IllegalActionException If the name has a period in it, or
071     *   the attribute is not compatible with the specified container.
072     *  @exception NameDuplicationException If the container already contains
073     *   an entity with the specified name.
074     */
075    public DependencyDeclaration(Variable container, String name)
076            throws IllegalActionException, NameDuplicationException {
077        super(container, name);
078        setPersistent(false);
079    }
080
081    ///////////////////////////////////////////////////////////////////
082    ////                         public methods                    ////
083
084    /** Return the list of dependents of the parameter that contains
085     *  this attribute.  This attribute declares that the container
086     *  depends on at least the given set of parameters.
087     *  @return A list of variables.
088     *  @see #setDependents
089     */
090    public List getDependents() {
091        return _dependents;
092    }
093
094    /** Set the set of dependents for this declaration.
095     *  @param dependents A list of variables.
096     *  @exception RuntimeException If the list of dependents is null.
097     *  @see #getDependents
098     */
099    public void setDependents(List dependents) {
100        if (dependents == null) {
101            throw new RuntimeException("Attempt to set dependents to null!");
102        }
103
104        _dependents = dependents;
105    }
106
107    ///////////////////////////////////////////////////////////////////
108    ////                         private variables                 ////
109    // The declared dependents.
110    private List _dependents;
111}