diff options
Diffstat (limited to 'src/mongo/db/catalog/database.h')
-rw-r--r-- | src/mongo/db/catalog/database.h | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/src/mongo/db/catalog/database.h b/src/mongo/db/catalog/database.h index 2a5e281c1b5..e5fab444357 100644 --- a/src/mongo/db/catalog/database.h +++ b/src/mongo/db/catalog/database.h @@ -31,8 +31,6 @@ #include <memory> #include <string> -#include "mongo/base/shim.h" -#include "mongo/base/status.h" #include "mongo/base/string_data.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/catalog/collection.h" @@ -47,7 +45,6 @@ #include "mongo/util/string_map.h" namespace mongo { - /** * Represents a logical database containing Collections. * @@ -126,34 +123,16 @@ public: virtual const CollectionMap& collections() const = 0; }; +private: + static std::unique_ptr<Impl> makeImpl(Database* _this, + OperationContext* opCtx, + StringData name, + DatabaseCatalogEntry* dbEntry); + public: - static MONGO_DECLARE_SHIM((OperationContext * opCtx)->void) dropAllDatabasesExceptLocal; + using factory_function_type = decltype(makeImpl); - /** - * Creates the namespace 'ns' in the database 'db' according to 'options'. If - * 'createDefaultIndexes' - * is true, creates the _id index for the collection (and the system indexes, in the case of - * system - * collections). Creates the collection's _id index according to 'idIndex', if it is non-empty. - * When - * 'idIndex' is empty, creates the default _id index. - */ - static MONGO_DECLARE_SHIM( - (OperationContext * opCtx, - Database* db, - StringData ns, - BSONObj options, - CollectionOptions::ParseKind parseKind = CollectionOptions::parseForCommand, - bool createDefaultIndexes = true, - const BSONObj& idIndex = BSONObj()) - ->Status) userCreateNS; - - static MONGO_DECLARE_SHIM((Database * this_, - OperationContext* opCtx, - StringData name, - DatabaseCatalogEntry*, - PrivateTo<Database>) - ->std::unique_ptr<Impl>) makeImpl; + static void registerFactory(stdx::function<factory_function_type> factory); /** * Iterating over a Database yields Collection* pointers. @@ -203,7 +182,7 @@ public: explicit inline Database(OperationContext* const opCtx, const StringData name, DatabaseCatalogEntry* const dbEntry) - : _pimpl(makeImpl(this, opCtx, name, dbEntry, PrivateCall<Database>{})) { + : _pimpl(makeImpl(this, opCtx, name, dbEntry)) { this->_impl().init(opCtx); } @@ -356,7 +335,17 @@ public: * * Must be called with the specified database locked in X mode. */ - static MONGO_DECLARE_SHIM((OperationContext * opCtx, Database* db)->void) dropDatabase; + static void dropDatabase(OperationContext* opCtx, Database* db); + + /** + * Registers an implementation of `Database::dropDatabase` for use by library clients. + * This is necessary to allow `catalog/database` to be a vtable edge. + * @param impl Implementation of `dropDatabase` to install. + * @note This call is not thread safe. + */ + static void registerDropDatabaseImpl(stdx::function<decltype(dropDatabase)> impl); + + // static Status validateDBName( StringData dbname ); inline const NamespaceString& getSystemIndexesName() const { return this->_impl().getSystemIndexesName(); @@ -406,4 +395,37 @@ private: std::unique_ptr<Impl> _pimpl; }; + +void dropAllDatabasesExceptLocal(OperationContext* opCtx); + +/** + * Registers an implementation of `dropAllDatabaseExceptLocal` for use by library clients. + * This is necessary to allow `catalog/database` to be a vtable edge. + * @param impl Implementation of `dropAllDatabaseExceptLocal` to install. + * @note This call is not thread safe. + */ +void registerDropAllDatabasesExceptLocalImpl( + stdx::function<decltype(dropAllDatabasesExceptLocal)> impl); + +/** + * Creates the namespace 'ns' in the database 'db' according to 'options'. If 'createDefaultIndexes' + * is true, creates the _id index for the collection (and the system indexes, in the case of system + * collections). Creates the collection's _id index according to 'idIndex', if it is non-empty. When + * 'idIndex' is empty, creates the default _id index. + */ +Status userCreateNS(OperationContext* opCtx, + Database* db, + StringData ns, + BSONObj options, + CollectionOptions::ParseKind parseKind = CollectionOptions::parseForCommand, + bool createDefaultIndexes = true, + const BSONObj& idIndex = BSONObj()); + +/** + * Registers an implementation of `userCreateNS` for use by library clients. + * This is necessary to allow `catalog/database` to be a vtable edge. + * @param impl Implementation of `userCreateNS` to install. + * @note This call is not thread safe. + */ +void registerUserCreateNSImpl(stdx::function<decltype(userCreateNS)> impl); } // namespace mongo |