MongoDB C++ Driver  legacy-1.0.3
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
init.h
1 // @file init.h
2 
3 /* Copyright 2013 10gen Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "mongo/base/status.h"
21 #include "mongo/client/export_macros.h"
22 #include "mongo/client/options.h"
23 
24 // NOTE: These functions are only intended to be used when linking against the libmongoclient
25 // library. The below functions are not defined in servers like mongos or mongod, which have
26 // their own initialization strategy.
27 
32 namespace mongo {
33 
38 namespace client {
39 
49  MONGO_CLIENT_API Status MONGO_CLIENT_FUNC initialize(const Options& options = Options());
50 
61  MONGO_CLIENT_API Status MONGO_CLIENT_FUNC shutdown();
62 
69  class MONGO_CLIENT_API GlobalInstance {
70 
71  MONGO_DISALLOW_COPYING(GlobalInstance);
72 
73  public:
83  explicit GlobalInstance(const Options& options = Options());
84 
90  ~GlobalInstance();
91 
93  const Status& status() const {
94  return _status;
95  }
96 
98  bool initialized() const {
99  return status().isOK();
100  }
101 
105  void assertInitialized() const;
106 
113  Status shutdown();
114 
115  private:
116  bool _terminateNeeded;
117  const Status _status;
118  };
119 
120 } // namespace client
121 } // namespace mongo
bool initialized() const
Returns 'true' if initialization succeeded, 'false' otherwise.
Definition: init.h:98
MONGO_CLIENT_API Status MONGO_CLIENT_FUNC shutdown()
Terminates the client driver.
the main MongoDB namespace
Definition: bulk_operation_builder.h:24
const Status & status() const
Returns the Status generated by the internal call to 'client::initialize'.
Definition: init.h:93
MONGO_CLIENT_API Status MONGO_CLIENT_FUNC initialize(const Options &options=Options())
Initializes the client driver, possibly with custom options.
The Options structure is passed to mongo::client::initialize to configure various properties and conf...
Definition: options.h:32
An RAII helper to simplify driver setup and teardown.
Definition: init.h:69
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.