001/* An atomic actor for testing Process Director.
002
003 Copyright (c) 1998-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.process.test;
029
030import ptolemy.actor.CompositeActor;
031import ptolemy.actor.test.TestActor;
032import ptolemy.kernel.util.IllegalActionException;
033import ptolemy.kernel.util.NameDuplicationException;
034
035///////////////////////////////////////////////////////////////////
036//// TestProcessActor
037
038/**
039 A TestProcessActor is a simple atomic actor that is used for testing the
040 actor package constructs for Processes. It overrides the action methods to
041 return false in the postfire after the first invocation of fire method.
042
043 @author Edward A. Lee, Mudit Goel
044 @version $Id$
045 @since Ptolemy II 0.2
046 @Pt.ProposedRating Yellow (eal)
047 @Pt.AcceptedRating Red (cxh)
048 */
049public class TestProcessActor extends TestActor {
050    /** Create a new actor in the specified container with the specified
051     *  name.  The name must be unique within the container or an exception
052     *  is thrown. The container argument must not be null, or a
053     *  NullPointerException will be thrown.
054     *
055     *  @param container The container.
056     *  @param name The name of this actor within the container.
057     *  @exception IllegalActionException If the entity cannot be contained
058     *   by the proposed container (see the setContainer() method).
059     *  @exception NameDuplicationException If the name coincides with
060     *   an entity already in the container.
061     */
062    public TestProcessActor(CompositeActor container, String name)
063            throws IllegalActionException, NameDuplicationException {
064        super(container, name);
065    }
066
067    ///////////////////////////////////////////////////////////////////
068    ////                         public methods                    ////
069
070    /** Record the firing and force postfire to return false.
071     *  @exception IllegalActionException If the super class throws it.
072     */
073    @Override
074    public void fire() throws IllegalActionException {
075        super.fire();
076        _notDone = false;
077    }
078
079    /** Record the invocation, then return true if fire was never called.
080     *  Else return false.
081     */
082    @Override
083    public boolean postfire() {
084        super.postfire();
085        return _notDone;
086    }
087
088    ///////////////////////////////////////////////////////////////////
089    ////                         private variables                 ////
090    private boolean _notDone = true;
091}