Prev | Next |
Object Oriented Programming In C
In Enterprise Architect, you apply a number of conventions for Object-Oriented programming in C.
To configure the system to support Object-Oriented programming using C, you must set the 'Object Oriented Support' option to True on the 'C Specifications' page of the 'Preferences' dialog.
Stereotypes
Stereotype |
Applies To |
See also |
---|---|---|
enumeration |
Class Corresponds To: An enumerated type. |
|
struct |
Class Corresponds To: A 'struct' type. |
|
Attribute |
A keyword struct in variable definition. |
|
typedef |
Class Corresponds To: A 'typedef' statement, where the parent is the original type name. |
|
union |
Class Corresponds To: A union type. |
|
Attribute |
A keyword union in variable definition. |
Tagged Values
Tag |
Applies To |
See also |
---|---|---|
anonymous |
Class with stereotype of 'enumeration', 'struct' or 'union' Corresponds To: The name of this Class being defined only by the typedef statement. |
|
bodyLocation |
Operation Corresponds To: The location the method body is generated to; expected values are 'header', 'classDec' or 'classBody'. |
|
define |
Attribute Corresponds To: '#define' statement. |
|
typedef |
Class with stereotype of 'enumeration', 'struct' or 'union' Corresponds To: This Class being defined in a 'typedef' statement. |
Object-Oriented C Code Generation for UML Model
The basic idea of implementing a UML Class in C code is to group the data variable (UML attributes) into a structure type; this structure is defined in a .h file so that it can be shared by other Classes and by the client that referred to it.
An operation in a UML Class is implemented in C code as a function; the name of the function must be a fully qualified name that consists of the operation name, as well as the Class name to indicate that the operation is for that Class.
A delimiter (specified in the 'Namespace Delimiter' option on the 'C Specifications' page) is used to join the Class name and function (operation) name.
The function in C code must also have a reference parameter to the Class object - you can modify the 'Reference as Operation Parameter', 'Reference Parameter Style' and 'Reference Parameter Name' options on the 'C Specifications' page to support this reference parameter.
Limitations of Object-Oriented Programming in C
Learn more