TECHLETTER 3

Singletons

The Singleton Design Pattern
using Rhapsody in C‘

There is a huge amount of different design patterns. The singleton design pattern is a simple, but also very useful pattern.

The pattern is used when there should only be a single instance (object) of a certain class. An example of the usage of the pattern is the realization of hardware classes for dealing with interrupts or certain devices. These can only exist once in the whole system. For instance, there may be multiple timers in the embedded systems, but in most cases, they only have one interrupt.

Therefore, the class for handling the interrupt can not be instantiated more than once and the singleton design pattern has to be used.

This Techletter shows you different possibilities to use it automatically or with some handwritten modification that offers you advantages!

What's in this Techletter:

  • What are Design Patterns?
  • What is a Singleton?
  • Singletons in Rhapsody in C‘
  • Singleton Classes
  • Singleton Objects
  • Class Functions
  • Class Variables
  • Extra Functions

Our other reports about Embedded Software Engineering