MongoDB C++ Driver  mongocxx-3.0.2
Public Member Functions | Static Public Member Functions | List of all members
mongocxx::instance Class Reference

Class representing an instance of the MongoDB driver. More...

#include <instance.hpp>

Public Member Functions

 instance ()
 Creates an instance of the driver.
 
 instance (std::unique_ptr< logger > logger)
 Creates an instance of the driver with a user provided log handler. More...
 
 instance (instance &&) noexcept
 Move constructs an instance of the driver.
 
instanceoperator= (instance &&) noexcept
 Move assigns an instance of the driver.
 
 ~instance ()
 Destroys an instance of the driver.
 

Static Public Member Functions

static instancecurrent ()
 Returns the current unique instance of the driver. More...
 

Detailed Description

Class representing an instance of the MongoDB driver.

Life cycle: A unique instance of the driver MUST be kept around.

Constructor & Destructor Documentation

mongocxx::instance::instance ( std::unique_ptr< logger logger)

Creates an instance of the driver with a user provided log handler.

Parameters
loggerThe logger that the driver will direct log messages to.
Exceptions
mongocxx::logic_errorif an instance already exists.

Member Function Documentation

static instance& mongocxx::instance::current ( )
static

Returns the current unique instance of the driver.

If an instance was explicitly created, that will be returned. If no instance has yet been created, a default instance will be constructed and returned. If a default instance is constructed, its destruction will be sequenced according to the rules for the destruction of static local variables at program exit (see http://en.cppreference.com/w/cpp/utility/program/exit).

Note that, if you need to configure the instance in any way (e.g. with a logger), you cannot use this method to cause the instance to be constructed. You must explicitly create an properly configured instance object. You can, however, use this method to obtain that configured instance object.

Note
This method is intended primarily for test authors, where managing the lifetime of the instance w.r.t. the test framework can be problematic.

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