IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.transform.uml2.cpp
Class CPPExtendClassifierRule

java.lang.Object
  extended bycom.ibm.xtools.transform.core.AbstractTransformElement
      extended bycom.ibm.xtools.transform.core.AbstractRule
          extended bycom.ibm.xtools.transform.uml2.cpp.CPPExtendFramework
              extended bycom.ibm.xtools.transform.uml2.cpp.CPPExtendRule
                  extended bycom.ibm.xtools.transform.uml2.cpp.CPPExtendClassifierRule
All Implemented Interfaces:
ITransformationItem
Direct Known Subclasses:
CPPExtendClassRule, CPPExtendInterfaceRule

public abstract class CPPExtendClassifierRule
extends CPPExtendRule

This class provides common functionality for the extensibility of the transformation of UML2 Classifiers into a C++ code. The source property of the rule context is expected to be a UML2 Classifier.


Nested Class Summary
 class CPPExtendClassifierRule.InheritanceKind
          List of the inheritance kinds supported by the transformation.
 class CPPExtendClassifierRule.StdOperationType
          List of the standard operations supported by the transformation.
 
Constructor Summary
CPPExtendClassifierRule(String id)
          Constructor.
 
Method Summary
protected  boolean addAttribute(String name, String type, org.eclipse.uml2.VisibilityKind visibility, String defaultValue, List array, String comment, boolean isStatic, boolean isConst, boolean isMutable, boolean isConstructorInitializer, ITransformContext ruleContext)
          Adds a C++ attribute with the specified properties to the generated C++ classifier.
protected  boolean addGeneralization(int generalizationKind, org.eclipse.uml2.Classifier superClassifier, ITransformContext ruleContext)
          Adds a C++ generalization with the specified properties.
protected  boolean addGeneralization(int generalizationKind, String superClass, ITransformContext ruleContext)
          Adds a C++ generalization with the specified properties.
protected  boolean addInclusion(org.eclipse.uml2.Element included, boolean isHeaderInclusion, ITransformContext ruleContext)
          Adds a C++ inclusion with the specified properties.
protected  boolean addInclusion(String headerString, String bodyString, ITransformContext ruleContext)
          Adds a C++ inclusion with the specified properties.
protected  boolean addOperation(String name, String returnType, org.eclipse.uml2.VisibilityKind visibility, String argumentsHeader, String argumentsBody, String comment, String body, boolean isInline, boolean isStatic, boolean isVirtual, boolean isPureVirtual, boolean isQuery, boolean isFriend, ITransformContext ruleContext)
          Adds a C++ operation with the specified properties to the generated classifier.
protected  boolean addStandardOperation(int operationType, org.eclipse.uml2.VisibilityKind visibility, String comment, String body, boolean isInline, boolean isVirtual, boolean isExplicit, ITransformContext ruleContext)
          Adds a standard C++ operation (constructor, destructor, copy constructor, or assignment operator) with the specified properties.
 boolean canAccept(ITransformContext context)
          The implementation of this method filters out contexts with inappropriate source elements, then calls canAcceptExt to provide additional filtering capabilities.
 
Methods inherited from class com.ibm.xtools.transform.uml2.cpp.CPPExtendRule
addBodyPrefix, addBodySuffix, addHeaderPrefix, addHeaderSuffix, isNested
 
Methods inherited from class com.ibm.xtools.transform.uml2.cpp.CPPExtendFramework
canAcceptExt, createTarget, createTargetExt
 
Methods inherited from class com.ibm.xtools.transform.core.AbstractRule
execute, findTarget, isSourceConsumed, mapTarget, toString, updateTarget
 
Methods inherited from class com.ibm.xtools.transform.core.AbstractTransformElement
getAcceptCondition, getDescription, getId, getName, getProgressMonitor, setAcceptCondition, setDescription, setId, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CPPExtendClassifierRule

public CPPExtendClassifierRule(String id)
Constructor.

Parameters:
id - A unique identifier for the rule.
Method Detail

canAccept

public boolean canAccept(ITransformContext context)
Description copied from class: CPPExtendFramework
The implementation of this method filters out contexts with inappropriate source elements, then calls canAcceptExt to provide additional filtering capabilities.

Overrides:
canAccept in class CPPExtendFramework
Parameters:
context - this rule execution context

addAttribute

protected final boolean addAttribute(String name,
                                     String type,
                                     org.eclipse.uml2.VisibilityKind visibility,
                                     String defaultValue,
                                     List array,
                                     String comment,
                                     boolean isStatic,
                                     boolean isConst,
                                     boolean isMutable,
                                     boolean isConstructorInitializer,
                                     ITransformContext ruleContext)
Adds a C++ attribute with the specified properties to the generated C++ classifier.

Parameters:
name - The name of the attribute.
type - The attribute's C++ type.
visibility - The attribute's visibility.
defaultValue - The attribute's initial value (include quotes for strings). Set to null if this attribute doesn't have an initial value.
array - List of attribute's array dimensions (i.e. 2,3 for "[2][3]"). List elements are expected to be of type "int". Set to null if C++ attribute doesn't represent an array.
comment - Comments to be added to the generated attribute. Set to null if this attribute has no comments.
isStatic - true: attribute is static.
isConst - true: attribute is const.
isMutable - true: attribute is mutable.
isConstructorInitializer - true: initialization of static attribute with default value is to be performed as constructor (i.e. "a(5)"); false - initialization of the static attribute will be performed via assignment (i.e. "a = 5").
ruleContext - This rule execution context. Must not be null.

addOperation

protected final boolean addOperation(String name,
                                     String returnType,
                                     org.eclipse.uml2.VisibilityKind visibility,
                                     String argumentsHeader,
                                     String argumentsBody,
                                     String comment,
                                     String body,
                                     boolean isInline,
                                     boolean isStatic,
                                     boolean isVirtual,
                                     boolean isPureVirtual,
                                     boolean isQuery,
                                     boolean isFriend,
                                     ITransformContext ruleContext)
Adds a C++ operation with the specified properties to the generated classifier. To create a standard operation (constructor, destructor, copy constructor, or assignment operator) use addStandardOperation.

Parameters:
name - The operation's name.
returnType - The operation's return type.
visibility - The attribute's visibility.
argumentsHeader - String containing operation's arguments for the header file.
argumentsBody - String containing operation's arguments for the body file. If null, argumentsHeader is used instead.
comment - Comments to be added to the generated operation. Set to null if this operation has no comments.
body - Body of the generated operation. Set to null if this operation has no body.
isInline - true: the operation is generated as inline.
isStatic - true: the operation is declared "static".
isVirtual - true: the operation is declared "virtual".
isPureVirtual - true: the operation is declared pure virtual.
isQuery - true: the operation is declared "const".
isFriend - true: The operation is declared as "friend".
ruleContext - This rule execution context. Must not be null.

addStandardOperation

protected final boolean addStandardOperation(int operationType,
                                             org.eclipse.uml2.VisibilityKind visibility,
                                             String comment,
                                             String body,
                                             boolean isInline,
                                             boolean isVirtual,
                                             boolean isExplicit,
                                             ITransformContext ruleContext)
Adds a standard C++ operation (constructor, destructor, copy constructor, or assignment operator) with the specified properties.

Parameters:
operationType - The operation type (use CPPExtendClassifierRule.StdOperationType to specify).
visibility - The attribute's visibility.
comment - Comments to be added to the generated standard operation. Set to null if this operation has no comments.
body - Body of the generated standard operation. If this parameter is set to null, standard body will be generated for the operation. Set to empty string if standard operation with no body is what's expected.
isInline - true: the operation is generated as inline.
isVirtual - true: the operation is declared "virtual".
isExplicit - true: the operation is declared "explicit".
ruleContext - This rule execution context. Must not be null.

addInclusion

protected final boolean addInclusion(org.eclipse.uml2.Element included,
                                     boolean isHeaderInclusion,
                                     ITransformContext ruleContext)
Adds a C++ inclusion with the specified properties.

Parameters:
included - The UML element being referenced.
isHeaderInclusion - true: "#include" directive added to the header (.h) file; false: forward reference added in the header (.h) file, "#include" directive added in the body (.cpp) file.
ruleContext - This rule execution context. Must not be null.

addInclusion

protected final boolean addInclusion(String headerString,
                                     String bodyString,
                                     ITransformContext ruleContext)
Adds a C++ inclusion with the specified properties. Note that text inclusions won't be validated or coalesced. This version adds inclusions to the top of the inclusions list.

Parameters:
headerString - String to be used for the header inclusion.
bodyString - String to be used for the body inclusion.
ruleContext - This rule execution context. Must not be null.

addGeneralization

protected final boolean addGeneralization(int generalizationKind,
                                          String superClass,
                                          ITransformContext ruleContext)
Adds a C++ generalization with the specified properties. Note that this method doesn't auto-generate inclusion.

Parameters:
generalizationKind - Inheritance kind (use CPPExtendClassifierRule.InheritanceKind).
superClass - String name of the super class.
ruleContext - This rule execution context. Must not be null.

addGeneralization

protected final boolean addGeneralization(int generalizationKind,
                                          org.eclipse.uml2.Classifier superClassifier,
                                          ITransformContext ruleContext)
Adds a C++ generalization with the specified properties. This method auto-generates an inclusion of the superclass.

Parameters:
generalizationKind - Inheritance type (use CPPExtendClassifierRule.InheritanceKind).
superClassifier - The UML super class.
ruleContext - This rule execution context. Must not be null.

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.