Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Object Oriented Programming In C

The following conventions are used for Object-Oriented programming in C.

To configure Enterprise Architect to support Object-Oriented programming using C, you must set the Object Oriented Support option to True on the C Specifications page of the Options dialog.

Reference

Stereotype

Stereotype

Applies To

Corresponds To

enumeration

Class

An enum type.

struct

Class

A struct type.

Attribute

A keyword struct in variable definition.

typedef

Class

A typedef statement, where the parent is the original type name.

union

Class

A union type.

Attribute

A keyword union in variable definition.

 
Tagged Values

Tag

Applies To

Corresponds To

anonymous

Class with stereotype of enumeration, struct or union

The name of this Class being defined only by the typedef statement.

bodyLocation

Operation

The location the method body is generated to; expected values are header, classDec or classBody.

define

Attribute

#define statement.

typedef

Class with stereotype of enumeration, struct or union

This Class being defined in a typedef statement.

Topics

Topic

Detail

See also

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.

 

C Specifications

Limitations of Object-Oriented Programming in C

·No scope mapping for an attribute: an attribute in a UML Class is mapped to a structure variable in C code, and its scope (private, protected or public) is ignored
·Currently an inner Class is ignored: if a UML Class is the inner Class of another UML Class, it is ignored when generating C code
·Initial value is ignored: the initial value of an attribute in a UML Class is ignored in generated C code

 

 

Learn more