001/* A director that does nothing.
002
003 Copyright (c) 2009-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;
029
030import ptolemy.kernel.CompositeEntity;
031import ptolemy.kernel.util.IllegalActionException;
032import ptolemy.kernel.util.NameDuplicationException;
033import ptolemy.kernel.util.Nameable;
034
035///////////////////////////////////////////////////////////////////
036//// DoNothingDirector
037
038/**
039 A director that does nothing, for use in models that have no useful
040 execution.
041
042 <p>This director is added to models for code generation purposes when
043 the model has no useful execution but the code generator runs
044 CompositeActor.preinitialize().</p>
045
046 <p>If this director is used in a model, then adding a <code>_hide</code>
047 attribute to the director will make the director invisible to the user.</p>
048
049 @author Edward A. Lee
050 @version $Id$
051 @since Ptolemy II 8.0
052 @Pt.ProposedRating Red (eal)
053 @Pt.AcceptedRating Red (cxh)
054 */
055public class DoNothingDirector extends Director {
056    /** Construct a director with the given container and name.
057     *  @param container The container.
058     *  @param name The name of this actor.
059     *  @exception IllegalActionException If the entity cannot be contained
060     *   by the proposed container.
061     *  @exception NameDuplicationException If the container already has an
062     *   actor with this name.
063     */
064    public DoNothingDirector(CompositeEntity container, String name)
065            throws NameDuplicationException, IllegalActionException {
066        super(container, name);
067    }
068
069    ///////////////////////////////////////////////////////////////////
070    ////                         public methods                    ////
071
072    @Override
073    public void addInitializable(Initializable initializable) {
074    }
075
076    @Override
077    public void fire() {
078    }
079
080    @Override
081    public void initialize() {
082    }
083
084    @Override
085    public boolean postfire() {
086        return false;
087    }
088
089    @Override
090    public boolean prefire() {
091        return false;
092    }
093
094    @Override
095    public void preinitialize() {
096        // When exporting the ClassesIllustrated model, the
097        // model would run forever because the value returned
098        // by prefire() was not being checked in Manager.
099        // If finish() is called then the bug would have
100        // been avoided.
101        Nameable container = getContainer();
102
103        if (container instanceof CompositeActor) {
104            ((CompositeActor) container).getManager().finish();
105        }
106    }
107
108    @Override
109    public boolean transferInputs(IOPort port) {
110        return false;
111    }
112
113    @Override
114    public boolean transferOutputs(IOPort port) {
115        return false;
116    }
117}