Singleton objects

Objects with a multiplicity of one that are tagged with the Singleton stereotype are instantiated only once throughout the life of the system. Singleton objects are implemented in C as a struct and functions. The singleton property is not enforced on the data, however.

A singleton object is declared as a struct in the specification file. For example:

struct object_0_t {
    /* attributes of object_0 */
};

The singleton object is instantiated as a package object in the implementation file, as follows:

struct object_0_t object_0;

Because there can be only one instance of a singleton, its operations do not include a context pointer as their first argument. For example, for a singleton object A with an operation op1() with one argument a1, the following function prototype is generated:

/*## operation op1(int) */
void A_op1(int a1);

If the same object were not a singleton, the following function prototype would be generated:

/*## operation op1(int) */
void A_op1(struct A_t* const me, int a1);

Feedback