Class MirrorDecorator

    • Field Detail

      • _decoratedObjects

        protected java.util.List<NamedObj> _decoratedObjects
        Cached list of decorated objects.
      • _decoratedObjectsVersion

        protected long _decoratedObjectsVersion
        Version for _decoratedObjects.
      • _listeners

        protected java.util.ArrayList<MirrorDecoratorListener> _listeners
        Listeners registered to receive events from this object.
      • _addedPortNames

        protected java.util.List<java.lang.String> _addedPortNames
        A list containing the names of user added ports.
      • _addedPortParameterNames

        protected java.util.List<java.lang.String> _addedPortParameterNames
        A list containing the names of user added port parameters.
      • _addedParameters

        protected java.util.List<Parameter> _addedParameters
        A list containing the user added parameters.
    • Constructor Detail

      • MirrorDecorator

        public MirrorDecorator​(CompositeEntity container,
                               java.lang.String name)
                        throws IllegalActionException,
                               NameDuplicationException
        Construct a MirrorDecorator with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        Description copied from class: NamedObj
        React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).
      • createDecoratorAttributes

        public DecoratorAttributes createDecoratorAttributes​(NamedObj target)
        Description copied from interface: Decorator
        Create and return the decorated attributes for the target NamedObj. Implementations of this method should create an Attribute that implements DecoratorAttributes. Implementations should populate that attribute with parameters that have appropriate default values.

        This method is called if NamedObj.getDecoratorAttribute(Decorator, String) or NamedObj.getDecoratorAttributes(Decorator) is called, and the specified target object does not already have decorated attributes for this decorator.

        The implementer of this method is responsible for ensuring consistency with the Decorator.decoratedObjects() method. Specifically, any object returned by Decorator.decoratedObjects(), when passed as an argument to this method, should not result in a null returned value. And conversely, any object passed to this method that is not in the list returned by decoratedObjects() should result in a null returned value.

        Specified by:
        createDecoratorAttributes in interface Decorator
        Parameters:
        target - The NamedObj that will be decorated.
        Returns:
        The decorated attributes for the target NamedObj, or null if the specified NamedObj is not decorated by this decorator.
      • getAddedPortNames

        public java.util.List<java.lang.String> getAddedPortNames()
        Return the added port names.
        Returns:
        a list containing the added port names
      • getAddedPortParameterNames

        public java.util.List<java.lang.String> getAddedPortParameterNames()
        Return the added port parameter names.
        Returns:
        a list containing the added port parameter names
      • getAddedParameters

        public java.util.List<Parameter> getAddedParameters()
        Return the added paramters.
        Returns:
        a list containing the added parameters.
      • isGlobalDecorator

        public boolean isGlobalDecorator()
        Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.
        Specified by:
        isGlobalDecorator in interface Decorator
        Returns:
        True if decorator is global.
      • registerListener

        public void registerListener​(MirrorDecoratorListener monitor)
        Add a communication aspect monitor to the list of listeners.
        Parameters:
        monitor - The communication aspect monitor.
      • sendPortEvent

        public void sendPortEvent​(MirrorDecoratorListener.DecoratorEvent eventType,
                                  java.lang.String portName)
        Notify the monitor that an event happened.
        Parameters:
        eventType - Type of event.
        portName - Name of port to be added/removed
      • sendParameterEvent

        public void sendParameterEvent​(MirrorDecoratorListener.DecoratorEvent eventType,
                                       Parameter parameter)
        Notify the monitor that an event happened.
        Parameters:
        eventType - Type of event.
        parameter - Parameter to be added/removed
      • _addPort

        protected void _addPort​(TypedIOPort port)
                         throws IllegalActionException,
                                NameDuplicationException
        Description copied from class: Entity
        Add a port to this entity. This method should not be used directly. Call the setContainer() method of the port instead. This method does not set the container of the port to point to this entity. It assumes that the port is in the same workspace as this entity, but does not check. The caller should check. Derived classes should override this method if they require a subclass of Port to throw an exception if the argument is not of an acceptable class. This method is not synchronized on the workspace, so the caller should be.
        Overrides:
        _addPort in class Entity<TypedIOPort>
        Parameters:
        port - The port to add to this entity.
        Throws:
        IllegalActionException - If the port has no name.
        NameDuplicationException - If the port name collides with a name already in the entity.
      • _removePort

        protected void _removePort​(Port port)
        Description copied from class: Entity
        Remove the specified port. This method should not be used directly. Call the setContainer() method of the port instead with a null argument. The port is assumed to be contained by this entity (otherwise, nothing happens). This method does not alter the container of the port. This method is not synchronized on the workspace, so the caller should be.
        Overrides:
        _removePort in class Entity<TypedIOPort>
        Parameters:
        port - The port being removed from this entity.
      • _addAttribute

        protected void _addAttribute​(Attribute attr)
                              throws NameDuplicationException,
                                     IllegalActionException
        Description copied from class: NamedObj
        Add an attribute. This method should not be used directly. Instead, call setContainer() on the attribute. Derived classes may further constrain the class of the attribute. To do this, they should override this method to throw an exception when the argument is not an instance of the expected class.

        This method is write-synchronized on the workspace and increments its version number.

        Overrides:
        _addAttribute in class NamedObj
        Parameters:
        attr - The attribute to be added.
        Throws:
        NameDuplicationException - If this object already has an attribute with the same name.
        IllegalActionException - If the attribute is not an an instance of the expect class (in derived classes).
      • _removeAttribute

        protected void _removeAttribute​(Attribute attr)
        Description copied from class: NamedObj
        Remove the given attribute. If there is no such attribute, do nothing. This method is write-synchronized on the workspace and increments its version. It should only be called by setContainer() in Attribute.
        Overrides:
        _removeAttribute in class NamedObj
        Parameters:
        attr - The attribute to be removed.