/* Container for decorator attributes that are provided to actors by * a resource scheduler. @Copyright (c) 2008-2014 The Regents of the University of California. All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. PT_COPYRIGHT_VERSION_2 COPYRIGHTENDKEY */ package ptolemy.actor; import ptolemy.data.BooleanToken; import ptolemy.data.expr.Parameter; import ptolemy.data.type.BaseType; import ptolemy.kernel.util.Attribute; import ptolemy.kernel.util.Decorator; import ptolemy.kernel.util.DecoratorAttributes; import ptolemy.kernel.util.IllegalActionException; import ptolemy.kernel.util.InternalErrorException; import ptolemy.kernel.util.KernelException; import ptolemy.kernel.util.NameDuplicationException; import ptolemy.kernel.util.NamedObj; /** Container for decorator attributes that are provided to actors by a ExecutionAspect. The resource scheduler decorates actors in a model with the attributes contained by this object. @author Patricia Derler @author Edward A. Lee @version $Id: ExecutionAttributes.java 70398 2014-10-22 23:44:32Z cxh $ @since Ptolemy II 10.0 @Pt.ProposedRating Yellow (eal) @Pt.AcceptedRating Red (eal) */ public class ExecutionAttributes extends DecoratorAttributes { /** Constructor to use when editing a model. * @param target The object being decorated. * @param decorator The decorator. * @exception IllegalActionException If the superclass throws it. * @exception NameDuplicationException If the superclass throws it. */ public ExecutionAttributes(NamedObj target, Decorator decorator) throws IllegalActionException, NameDuplicationException { super(target, decorator); _init(); } /** Constructor to use when parsing a MoML file. * @param target The object being decorated. * @param name The name of this attribute. * @exception IllegalActionException If the superclass throws it. * @exception NameDuplicationException If the superclass throws it. */ public ExecutionAttributes(NamedObj target, String name) throws IllegalActionException, NameDuplicationException { super(target, name); _init(); } /////////////////////////////////////////////////////////////////// //// parameters //// /** The enable parameter specifies whether the decorated actor uses * the resource scheduler decorator. * This is a boolean that defaults to false. */ public Parameter enable; /////////////////////////////////////////////////////////////////// //// public methods //// /** React to a change in an attribute. If the attribute is * enable, remember the value. * @param attribute The attribute that changed. * @exception IllegalActionException If the change is not acceptable * to this container (not thrown in this base class). */ @Override public void attributeChanged(Attribute attribute) throws IllegalActionException { if (attribute == enable) { _enabled = ((BooleanToken) enable.getToken()).booleanValue(); } super.attributeChanged(attribute); } /** Return whether the decorator associated with this attribute is * enabled. * @return True if enabled. */ public boolean enabled() { return _enabled; } /////////////////////////////////////////////////////////////////// //// private methods //// /** Create the parameters. */ private void _init() { try { enable = new Parameter(this, "enable"); enable.setExpression("false"); enable.setTypeEquals(BaseType.BOOLEAN); } catch (KernelException ex) { // This should not occur. throw new InternalErrorException(ex); } } private boolean _enabled; }