MongoDB C++ Driver  legacy-1.1.2
Public Member Functions | List of all members
mongo::client::GlobalInstance Class Reference

An RAII helper to simplify driver setup and teardown. More...

#include <init.h>

Public Member Functions

 GlobalInstance (const Options &options=Options())
 Invokes 'mongo::client::initialize" with the provided Options, or the default Options if none are provided. More...
 
 ~GlobalInstance ()
 Invokes 'mongo::client::shutdown' if the GlobalInstance succeeded in initializing the library and if the options used to successfully initialize the driver will not automatically result in a call to 'mongo::client::shutdown' during atexit processing.
 
const Statusstatus () const
 Returns the Status generated by the internal call to 'client::initialize'. More...
 
bool initialized () const
 Returns 'true' if initialization succeeded, 'false' otherwise. More...
 
void assertInitialized () const
 Raises a UserAssertion exception if the GlobalInstance failed to initialize the library.
 
Status shutdown ()
 Immediately calls 'shutdown' on the driver and returns the resulting Status. More...
 

Detailed Description

An RAII helper to simplify driver setup and teardown.

If more refined control over error handling of initialization and shutdown is required, use the explicit 'initialize' and 'shutdown' functions above. Note that the restrictions on the invocation of 'initialize' are not obviated by using this class. Please see the methods below for more details.

Constructor & Destructor Documentation

mongo::client::GlobalInstance::GlobalInstance ( const Options options = Options())
explicit

Invokes 'mongo::client::initialize" with the provided Options, or the default Options if none are provided.

If initialization is successful, destruction of the GlobalInstance will invoke 'shutdown' if such a call would not otherwise automatically be performed by the library via atexit (see Options::setCallShutdownAtExit). After constructing the GlobalInstance, you must check whether the initialization was successful via the 'initialized' method, or by checking the Status object returned by the 'status' member function. A failed GLobalInstance will not attempt to invoke shutdown.

Member Function Documentation

bool mongo::client::GlobalInstance::initialized ( ) const
inline

Returns 'true' if initialization succeeded, 'false' otherwise.

Status mongo::client::GlobalInstance::shutdown ( )

Immediately calls 'shutdown' on the driver and returns the resulting Status.

If the returned Status is OK, then the GlobalInstance will abandon the pending call to 'shutdown' from its destructor. If the returned Status is not an OK status, then the pending call to 'shutdown' is not canceled. The call to GlobalInstance::shutdown may be retried if it returns a non-OK Status.

const Status& mongo::client::GlobalInstance::status ( ) const
inline

Returns the Status generated by the internal call to 'client::initialize'.


The documentation for this class was generated from the following file: