Implementing objects in C
Objects are the structural building blocks of a system. They form a cohesive unit of state (data) and services (behavior). Every object has a specification part (public) and an implementation part (private).
In
terms
of C programming, an object is implemented
as a set of data members packed in a struct
, and
a set of related operations. With multiple instances, the data for
an object are replicated for each occurrence of the object.
For example, the following structure definition
is generated in the specification file for an object A
:
struct A_t {
/* data members of A */
};
/* operations of A */
Some details of the implementation might differ for special types of objects (for example, see Singleton objects).
Note: Because C structures cannot be empty, if the object does not have data or a
statechart, an
RIC_EMPTY_STRUCT
member is added as a placeholder to satisfy the C
compiler. RIC_EMPTY_STRUCT
is a macro defined in the Rhapsody® Developer for C
framework.