Interface Decorator
-
- All Superinterfaces:
Nameable
- All Known Subinterfaces:
ActorExecutionAspect
- All Known Implementing Classes:
AccessorCodeGenerator
,AccessorSSHCodeGenerator
,AFDXESs
,AFDXSwitch
,AtomicCommunicationAspect
,AtomicExecutionAspect
,BasicSwitch
,Bus
,CanBus
,CCodeGenerator
,CompositeCommunicationAspect
,CompositeExecutionAspect
,ConstraintMonitor
,CrossbarSwitch
,DynamicCoreAssignmentScheduler
,EDFScheduler
,FCFSScheduler
,FixedPriorityScheduler
,FMIMACodeGenerator
,FMIMAHybridCodeGenerator
,GaussianMeasurementModel
,GenericCodeGenerator
,GiottoDirector
,GiottoTimingManager
,HMMGaussianEstimator
,HTMLCodeGenerator
,JavaCodeGenerator
,Map
,MeasurementModel
,MirrorDecorator
,ModularCodeGenerator
,ModularSDFCodeGenerator
,PacketDropFaultGenerator
,ParameterEstimator
,ProceduralCodeGenerator
,ProgramCodeGenerator
,PtidesDirector
,PtidyOSCodeGenerator
,RunnableCodeGenerator
,StateSpaceModel
,StuckAtFaultGenerator
,SyntacticCodeGenerator
,TestGenericCodeGenerator
,TTESwitch
,VariableDelaySwitch
public interface Decorator extends Nameable
A decorator is a class that decorates other instances of NamedObj with extra attributes that are specific to both the decorator and the NamedObj. Those extra attributes are contained by an attribute of classDecoratorAttributes
that is created by callingcreateDecoratorAttributes(NamedObj)
and specifying the object that will contain the additional attributes. The decorated NamedObj will contain these instances of DecoratorAttributes. These attributes are stored separately and can be retrieved by usingNamedObj.getDecoratorAttributes(Decorator)
orNamedObj.getDecoratorAttributes(Decorator)
.NOTE: An implementer of this interface should override the setContainer() method to look for objects that will be in scope with the new container and establish a connection with them. Specifically, it should do this:
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException { super.setContainer(container); if (container != null) { List<NamedObj> decoratedObjects = decoratedObjects(); for (NamedObj decoratedObject : decoratedObjects) { // The following will create the DecoratorAttributes if it does not // already exist, and associate it with this decorator. decoratedObject.getDecoratorAttributes(this); } } }
For a description of a decorator pattern, see http://en.wikipedia.org/wiki/Decorator_pattern.
- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Bert Rodiers, Edward A. Lee
- Pt.AcceptedRating:
- Red (rodiers)
- Pt.ProposedRating:
- Red (rodiers)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Create and return the decorated attributes for the target NamedObj.java.util.List<NamedObj>
decoratedObjects()
Return a list of the objects that this decorator decorates.boolean
isGlobalDecorator()
Return true if this decorator should decorate objects across opaque hierarchy boundaries.-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Method Detail
-
createDecoratorAttributes
DecoratorAttributes createDecoratorAttributes(NamedObj target) throws IllegalActionException
Create and return the decorated attributes for the target NamedObj. Implementations of this method should create an Attribute that implementsDecoratorAttributes
. Implementations should populate that attribute with parameters that have appropriate default values.This method is called if
NamedObj.getDecoratorAttribute(Decorator, String)
orNamedObj.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
decoratedObjects()
method. Specifically, any object returned bydecoratedObjects()
, 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.- 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.
- Throws:
IllegalActionException
- If the target cannot be determined to be decorated or not (e.g., a parameter cannot be evaluated).
-
decoratedObjects
java.util.List<NamedObj> decoratedObjects() throws IllegalActionException
Return a list of the objects that this decorator decorates. This could be, for example, all of the entities contained by the container of this decorator. An implementer of this method is responsible for ensuring thatcreateDecoratorAttributes(NamedObj)
will not return null for any object included in the returned list.Implementers of this method are required to maintain consistency with
createDecoratorAttributes(NamedObj)
.- Returns:
- A list of the objects decorated by this decorator.
- Throws:
IllegalActionException
- If some object cannot be determined to be decorated or not (e.g., a parameter cannot be evaluated).
-
isGlobalDecorator
boolean isGlobalDecorator() throws IllegalActionException
Return true if this decorator should decorate objects across opaque hierarchy boundaries. That is, return true to make this decorator visible to objects even within opaque composites.- Returns:
- True if decorator is global.
- Throws:
IllegalActionException
- If it cannot be determined whether this is global or not (e.g., a parameter cannot be evaluated).
-
-