001/*
002 * Copyright (c) 2005-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: welker $'
006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 
007 * '$Revision: 24234 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.sms;
031
032import ptolemy.data.type.Type;
033import ptolemy.kernel.Entity;
034import ptolemy.kernel.util.Attribute;
035import ptolemy.kernel.util.IllegalActionException;
036import ptolemy.kernel.util.NameDuplicationException;
037import ptolemy.kernel.util.NamedObj;
038
039/**
040 * A virtual IO port is a basic (property) attribute. The name of the property
041 * is the name of the (virtual) IO port.
042 * 
043 * @author Shawn Bowers
044 * @created June 15, 2005
045 */
046
047public abstract class KeplerVirtualIOPort extends Attribute {
048
049        /**
050         * Constructor
051         * 
052         * @param container
053         *            Description of the Parameter
054         * @param name
055         *            The value of the property
056         * @exception IllegalActionException
057         *                Description of the Exception
058         * @exception NameDuplicationException
059         *                Description of the Exception
060         */
061        public KeplerVirtualIOPort(NamedObj container, String name)
062                        throws IllegalActionException, NameDuplicationException {
063                super(container, name);
064        }
065
066        /**
067         * @return True if the port is considered an output.
068         */
069        public abstract boolean isOutput();
070
071        /**
072         * @return True if the port is considered an input.
073         */
074        public abstract boolean isInput();
075
076        /**
077         * @return The data type of the virtual port. If no type exists, then null.
078         */
079        public abstract Type getType();
080
081        /**
082         * Set the container of the virtual port to the given container. This method
083         * fails, in addition to the normal ptolemy constraints for setting
084         * containers, if the given container is not a ptolemy.kernel.Entity object.
085         * 
086         * @param container
087         *            The container for this virtual port.
088         */
089        public void setContainer(NamedObj container) throws IllegalActionException,
090                        NameDuplicationException {
091                if (!(container instanceof Entity)) {
092                        String msg = "Container not an instance of ptolemy.kernel.Entity for virtual port '"
093                                        + getName() + "'";
094                        throw new IllegalActionException(this, msg);
095                }
096                super.setContainer(container);
097        }
098
099} // KeplerVirtualIOPort