NamedRegistries

   
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 .

Figure C-7. The singleton class NamedRegistries
figs/utf_ac07.gif

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 std::set<TestFactory*> Factories

Defines the type Factories as a set of TestFactory ( private ).


Registries m_registries

Contains managed instances of TestFactoryRegistry ( private ).


Factories m_destroyedFactories

Contains instances of TestFactory that have been destroyed ( private ).


Factories m_factoriesToDestroy

Contains instances of TestFactory that need to be destroyed ( private ).



Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net