001/* A parameter to store an integer number priority in an actor.
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.parameters;
029
030import ptolemy.data.expr.Parameter;
031import ptolemy.data.type.BaseType;
032import ptolemy.kernel.util.IllegalActionException;
033import ptolemy.kernel.util.NameDuplicationException;
034import ptolemy.kernel.util.NamedObj;
035
036//////////////////////////////////////////////////////////////////////////
037//// PriorityParameter
038
039/**
040 A parameter to store an integer number priority in an actor. The default
041 priority is 0. A smaller number designates a higher priority. In an execution
042 with a timed model of computation, such as DE, when two actors are scheduled
043 with the same timestamp and microstep, they are fired according to the priority
044 specified for them. The actor with a smaller priority number is fired before
045 the one with a greater priority number.
046
047 @author Thomas Huining Feng
048 @version $Id$
049 @since Ptolemy II 8.0
050 @Pt.ProposedRating Red (tfeng)
051 @Pt.AcceptedRating Red (tfeng)
052 */
053public class Priority extends Parameter {
054
055    /** Construct a priority parameter with the given name contained by the
056     *  specified entity. The container argument must not be null, or a
057     *  NullPointerException will be thrown.  This parameter will use the
058     *  workspace of the container for synchronization and version counts.
059     *  If the name argument is null, then the name is set to the empty string.
060     *  The object is not added to the list of objects in the workspace
061     *  unless the container is null.
062     *  Increment the version of the workspace.
063     *  @param container The container.
064     *  @param name The name of the parameter.
065     *  @exception IllegalActionException If the parameter is not of an
066     *   acceptable class for the container.
067     *  @exception NameDuplicationException If the name coincides with
068     *   a parameter already in the container.
069     */
070    public Priority(NamedObj container, String name)
071            throws IllegalActionException, NameDuplicationException {
072        super(container, name);
073
074        setTypeEquals(BaseType.INT);
075        setExpression("0");
076    }
077}