Name

NamedRegistries

Description

The class NamedRegistries (see Figure C-7) manages all instances of TestFactoryRegistry and is responsible for their creation and destruction. It also keeps track of which instances of TestFactory have been destroyed, thus preventing multiple deletions.

NamedRegistries is a singleton: there is one and only one static instance of it. Thus, it has no constructor. A reference to the single NamedRegistries object is obtained using its static getInstance( ) method.

NamedRegistries belongs to the namespace CppUnit. It is declared and implemented in TestFactoryRegistry.cpp.

The singleton class NamedRegistries
Figure C-7. The singleton class NamedRegistries

Declaration

class NamedRegistries

Constructors/Destructors

~NamedRegistries( )

A destructor. Deletes all instances of TestFactoryRegistry.

Public Methods

static NamedRegistries& getInstance( )

Gets a reference to the single NamedRegistries object.

TestFactoryRegistry& getRegistry(string name)

Returns the named TestFactoryRegistry if it exists; otherwise, creates a new one with the given name and returns it.

bool needDestroy(TestFactory *factory)

Returns TRUE if factory has not yet been destroyed.

void wasDestroyed(TestFactory *factory)

Signals that factory was destroyed.

Protected/Private Methods

None.

Attributes

typedef map<string, TestFactoryRegistry*> Registries

Defines the type Registries as a map of TestFactoryRegistry by name (private).

typedef ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.