001/* Interface with basic method for initializing and executing components.
002
003 Copyright (c) 1997-2013 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 */
027package ptolemy.component;
028
029import ptolemy.kernel.util.IllegalActionException;
030
031///////////////////////////////////////////////////////////////////
032//// Component
033
034/**
035 This interface defines the basic methods for initializing and
036 executing components. The intended usage is that preinitialize()
037 is invoked exactly once in an execution of a model, before any
038 static analysis such as scheduling or type resolution is done.
039 The initialize() method may be invoked more than once to
040 initialize() a component, and it is invoked after static analysis.
041 The run() method may be invoked multiple times after initialize().
042 The wrapup() method is invoked exactly once at the end of an
043 execution of a model. It is important that an implementor ensure
044 that wrapup() is called even if an exception occurs.
045
046 @author Yang Zhao and Edward A. Lee
047 @version $Id$
048 @since Ptolemy II 11.0
049 @Pt.ProposedRating yellow (ellen_zh)
050 @Pt.AcceptedRating red (davisj)
051 */
052public interface Component {
053    ///////////////////////////////////////////////////////////////////
054    ////                         public methods                    ////
055
056    /** Initialize the component.  This is invoked once after
057     *  preinitialize() and again whenever the component needs
058     *  to be reinitialized.
059     *  @exception IllegalActionException If initialization
060     *   cannot be completed.
061     */
062    public void initialize() throws IllegalActionException;
063
064    /** Preinitialize the component. This is invoked exactly
065     *  once per execution of a model, before any other methods
066     *  in this interface are invoked.
067     *  @exception IllegalActionException If preinitialization
068     *   cannot be completed.
069     */
070    public void preinitialize() throws IllegalActionException;
071
072    /** Execute the component. This is invoked after preinitialize()
073     *  and initialize(), and may be invoked repeatedly.
074     * @exception IllegalActionException If the run cannot be completed.
075     */
076    public void run() throws IllegalActionException;
077
078    /** Wrap up an execution. This method is invoked exactly once
079     *  per execution of a model. It finalizes an execution, typically
080     *  closing files, displaying final results, etc. If any other
081     *  method from this interface is invoked after this, it must
082     *  begin with preinitialize().
083     *  @exception IllegalActionException If wrapup fails.
084     */
085    public void wrapup() throws IllegalActionException;
086}