001/** Interface for objects with types.
002
003 Copyright (c) 1997-2006 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
028 */
029package ptolemy.data.type;
030
031import ptolemy.graph.InequalityTerm;
032import ptolemy.kernel.util.IllegalActionException;
033
034//////////////////////////////////////////////////////////////////////////
035//// Typeable
036
037/**
038 Interface for objects with types. This interface defines methods for
039 setting and getting types and type constraints. Type constraints are
040 represented as inequalities between Typeable objects.
041
042 @author Yuhong Xiong, Xiaojun Liu, Edward A. Lee
043 @version $Id$
044 @since Ptolemy II 0.4
045 @Pt.ProposedRating Red (yuhong)
046 @Pt.AcceptedRating Red (cxh)
047 @see ptolemy.graph.InequalityTerm
048 */
049public interface Typeable extends HasTypeConstraints {
050    /** Return the type of this object. An exception is thrown if the type
051     *  cannot be determined. This can happen if the type of this object
052     *  is dependent on some other objects whose value is not available yet.
053     *  @return An instance of Type.
054     *  @exception IllegalActionException If the type cannot be determined.
055     */
056    public Type getType() throws IllegalActionException;
057
058    /** Return an InequalityTerm representing this object.
059     *  @return An InequalityTerm.
060     */
061    public InequalityTerm getTypeTerm();
062
063    /** Check whether the type of this object is acceptable.
064     *  @return True if the type of this object is acceptable.
065     */
066    public boolean isTypeAcceptable();
067
068    /** Constrain the type of this object to be equal to or greater
069     *  than the type of the argument.  Notice that this constraint
070     *  is not enforced until type resolution is done, and is not
071     *  enforced if type resolution is not done.
072     *  @param lesser A Typeable object.
073     */
074    public void setTypeAtLeast(Typeable lesser);
075
076    /** Constrain the type of this object to be equal to or greater
077     *  than the type represented by the specified InequalityTerm. Notice
078     *  that this constraint is not enforced until type resolution is done,
079     *  and is not enforced if type resolution is not done.
080     *  @param typeTerm An InequalityTerm object.
081     */
082    public void setTypeAtLeast(InequalityTerm typeTerm);
083
084    /** Constrain the type of this object to be equal to or less
085     *  than the argument.  Because the argument is a concrete type,
086     *  rather than a Typeable object (which may not yet have a type),
087     *  the constraint is immediately enforced.
088     *  @param type An instance of Type.
089     *  @exception IllegalActionException If the type of this object
090     *   already violates this constraint.
091     */
092    public void setTypeAtMost(Type type) throws IllegalActionException;
093
094    /** Set a type constraint that the type of this object equal
095     *  the specified value.
096     *  @param type An instance of Type.
097     *  @exception IllegalActionException If the type of this object
098     *   already violates this constraint.
099     */
100    public void setTypeEquals(Type type) throws IllegalActionException;
101
102    /** Constrain the type of this object to be the same as the
103     *  type of the argument.  Notice that this constraint
104     *  is not enforced until type resolution is done, and is not
105     *  enforced if type resolution is not done.
106     *  @param equal The type that this object should be the same as.
107     */
108    public void setTypeSameAs(Typeable equal);
109}