Public Member Functions | Private Attributes

cmtk::ExitException Class Reference
[cmtkSystem Library]

Program exit exception class. More...

#include <cmtkExitException.h>

Inheritance diagram for cmtk::ExitException:
Inheritance graph
[legend]
Collaboration diagram for cmtk::ExitException:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ExitException (const int exitCode=0)
 Constructor.
virtual ~ExitException () throw ()
 Virtual destructor.
virtual const char * what () const throw ()
 Overwrite inherited "what" member.
int ExitCode () const
 Return exit code.

Private Attributes

const int m_ExitCode
 Program exit code.

Detailed Description

Program exit exception class.

Throwing an object of this class should return control to the global main() function, which should exit() with the given exit status. This should ensure that all local automatic as well as global static objects have their destructors called.

The global main() function can make use of this exception via the following wrapper construct,

 int
 main( const int argc, const char* argv[] )
 {
   int exitCode = 0;
   try
     {
     exitCode = doMain( argc, argv );
     }
   catch ( const cmtk::ExitException& ex )
     {
     exitCode = ex.ExitCode();
     }
   return exitCode;
 }
 *

where the actual function of the program is moved into the doMain() implementation function.

Definition at line 76 of file cmtkExitException.h.


Constructor & Destructor Documentation

cmtk::ExitException::ExitException ( const int  exitCode = 0 ) [inline]

Constructor.

Parameters:
exitCodeProgram exit code.

Definition at line 83 of file cmtkExitException.h.

virtual cmtk::ExitException::~ExitException (  ) throw () [inline, virtual]

Virtual destructor.

Definition at line 86 of file cmtkExitException.h.


Member Function Documentation

int cmtk::ExitException::ExitCode (  ) const [inline]

Return exit code.

Definition at line 95 of file cmtkExitException.h.

virtual const char* cmtk::ExitException::what (  ) const throw () [inline, virtual]

Overwrite inherited "what" member.

Definition at line 89 of file cmtkExitException.h.


Member Data Documentation

const int cmtk::ExitException::m_ExitCode [private]

Program exit code.

Definition at line 102 of file cmtkExitException.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines