diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2018-04-30 18:34:19 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2018-04-30 18:34:19 -0400 |
commit | 00ca22fc7097455ab1301931015a86d84e038744 (patch) | |
tree | b3886adb9020c09eab0e77d8ceb08d31cf8ebc7c /src/mongo/db/catalog/database.cpp | |
parent | c68c5f493b042350f61dff7aaa32aa2e3e6d651e (diff) | |
download | mongo-00ca22fc7097455ab1301931015a86d84e038744.tar.gz |
SERVER-32645 Create a shim helper framework.
The `MONGO_DECLARE_SHIM`, `MONGO_DEFINE_SHIM`, and `MONGO_REGISTER_SHIM`
macros can be used to create specialized types which are customization
and auto-registration points for late-binding functions. In some
sense they work like weak-symbols; however, they also are useful for
tracking dependencies upon shimmed-out implementations.
Diffstat (limited to 'src/mongo/db/catalog/database.cpp')
-rw-r--r-- | src/mongo/db/catalog/database.cpp | 61 |
1 files changed, 4 insertions, 57 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index 527c9e847ab..a9963a2dc7d 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -36,66 +36,13 @@ namespace mongo { Database::Impl::~Impl() = default; -namespace { -stdx::function<Database::factory_function_type> factory; -} // namespace - -void Database::registerFactory(decltype(factory) newFactory) { - factory = std::move(newFactory); -} - -auto Database::makeImpl(Database* const this_, - OperationContext* const opCtx, - const StringData name, - DatabaseCatalogEntry* const dbEntry) -> std::unique_ptr<Impl> { - return factory(this_, opCtx, name, dbEntry); -} +MONGO_DEFINE_SHIM(Database::makeImpl); void Database::TUHook::hook() noexcept {} -namespace { -stdx::function<decltype(Database::dropDatabase)> dropDatabaseImpl; -} - -void Database::dropDatabase(OperationContext* const opCtx, Database* const db) { - return dropDatabaseImpl(opCtx, db); -} +MONGO_DEFINE_SHIM(Database::dropDatabase); -void Database::registerDropDatabaseImpl(stdx::function<decltype(dropDatabase)> impl) { - dropDatabaseImpl = std::move(impl); -} +MONGO_DEFINE_SHIM(Database::userCreateNS); -namespace { -stdx::function<decltype(userCreateNS)> userCreateNSImpl; -stdx::function<decltype(dropAllDatabasesExceptLocal)> dropAllDatabasesExceptLocalImpl; -} // namespace +MONGO_DEFINE_SHIM(Database::dropAllDatabasesExceptLocal); } // namespace mongo - -auto mongo::userCreateNS(OperationContext* const opCtx, - Database* const db, - const StringData ns, - const BSONObj options, - const CollectionOptions::ParseKind parseKind, - const bool createDefaultIndexes, - const BSONObj& idIndex) -> Status { - return userCreateNSImpl(opCtx, db, ns, options, parseKind, createDefaultIndexes, idIndex); -} - -void mongo::registerUserCreateNSImpl(stdx::function<decltype(userCreateNS)> impl) { - userCreateNSImpl = std::move(impl); -} - -void mongo::dropAllDatabasesExceptLocal(OperationContext* const opCtx) { - return dropAllDatabasesExceptLocalImpl(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 mongo::registerDropAllDatabasesExceptLocalImpl( - stdx::function<decltype(dropAllDatabasesExceptLocal)> impl) { - dropAllDatabasesExceptLocalImpl = std::move(impl); -} |