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.
![]() |
Declaration
class NamedRegistries
Constructors/Destructors
-
~NamedRegistries( ) A destructor. Deletes all instances of
TestFactoryRegistry.
Public Methods
-
static NamedRegistries& getInstance( ) Gets a reference to the single
NamedRegistriesobject.-
TestFactoryRegistry& getRegistry(string name) Returns the named
TestFactoryRegistryif it exists; otherwise, creates a new one with the given name and returns it.-
bool needDestroy(TestFactory *factory) Returns
TRUEiffactoryhas not yet been destroyed.-
void wasDestroyed(TestFactory *factory) Signals that
factorywas destroyed.
Protected/Private Methods
None.
Attributes
-
typedef map<string, TestFactoryRegistry*> Registries Defines the type
Registriesas amapofTestFactoryRegistryby name (private).-
typedef ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
