Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
Injects run-time dependency of a class on TimeMonitor. More...
#include <Teuchos_TimeMonitor.hpp>
Public Member Functions | |
TimeMonitorSurrogateImplInserter () | |
Constructor: inject dependency on TimeMonitor into CommandLineProcessor. More... | |
Injects run-time dependency of a class on TimeMonitor.
Classes and functions with the name "TimeMonitorSurrogate" in them let CommandLineProcessor optionally call TimeMonitor::summarize(), without needing to know that the TimeMonitor class exists. This allows Teuchos to put CommandLineProcessor in a separate package from TimeMonitor. We want to do this because TimeMonitor depends on Comm, and is therefore in the TeuchosComm subpackage (which depends on TeuchosCore), but CommandLineProcessor is in a different subpackage which does not depend on Comm.
The TimeMonitorSurrogateImplInserter class' constructor ensures that CommandLineProcessor gets informed about TimeMonitor even before the program starts executing main(). This happens automatically, without changes to main(), because we declare an instance of this class in the header file. If the TeuchosComm subpackage was built and its libraries were linked in, CommandLineProcessor will know about TimeMonitor.
This is an instance of the Dependency injection design pattern. CommandLineProcessor is not supposed to know about TimeMonitor, because CommandLineProcessor's subpackage does not depend on TimeMonitor's subpackage. Thus, CommandLineProcessor interacts with TimeMonitor through the TimeMonitorSurrogate interface. TimeMonitorSurrogateImplInserter "injects" the dependency at run time, if the TeuchosComm subpackage was enabled and the application linked with its libraries.
Teuchos developers could imitate the pattern of this class in order to use TimeMonitor's class methods (such as summarize()) from any other class that does not depend on the TeuchosComm subpackage.
Definition at line 860 of file Teuchos_TimeMonitor.hpp.
|
inline |
Constructor: inject dependency on TimeMonitor into CommandLineProcessor.
Definition at line 863 of file Teuchos_TimeMonitor.hpp.