Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::ExtensionManager Class Reference
Collaboration diagram for duckdb::ExtensionManager:

Public Member Functions

 ExtensionManager (DatabaseInstance &db)
DUCKDB_API bool ExtensionIsLoaded (const string &name)
DUCKDB_API vector< string > GetExtensions ()
DUCKDB_API optional_ptr< ExtensionInfo > GetExtensionInfo (const string &name)
DUCKDB_API unique_ptr< ExtensionActiveLoad > BeginLoad (const string &extension)

Static Public Member Functions

static DUCKDB_API ExtensionManager & Get (DatabaseInstance &db)
static DUCKDB_API ExtensionManager & Get (ClientContext &context)

Private Attributes

DatabaseInstance & db
mutex lock
unordered_map< string, unique_ptr< ExtensionInfo > > loaded_extensions_info

Constructor & Destructor Documentation

◆ ExtensionManager()

duckdb::ExtensionManager::ExtensionManager ( DatabaseInstance & db)
explicit
281377 : db(db) {
281378}

Member Function Documentation

◆ ExtensionIsLoaded()

bool duckdb::ExtensionManager::ExtensionIsLoaded ( const string & name)
281409 {
281410 auto info = GetExtensionInfo(name);
281411 if (!info) {
281412 return false;
281413 }
281414 return info->is_loaded;
281415}

◆ GetExtensions()

vector< string > duckdb::ExtensionManager::GetExtensions ( )
281399 {
281400 lock_guard<mutex> guard(lock);
281401
281402 vector<string> result;
281403 for (auto &entry : loaded_extensions_info) {
281404 result.push_back(entry.first);
281405 }
281406 return result;
281407}

◆ GetExtensionInfo()

optional_ptr< ExtensionInfo > duckdb::ExtensionManager::GetExtensionInfo ( const string & name)
281388 {
281389 auto extension_name = ExtensionHelper::GetExtensionName(name);
281390
281391 lock_guard<mutex> guard(lock);
281392 auto entry = loaded_extensions_info.find(extension_name);
281393 if (entry == loaded_extensions_info.end()) {
281394 return nullptr;
281395 }
281396 return entry->second.get();
281397}

◆ BeginLoad()

unique_ptr< ExtensionActiveLoad > duckdb::ExtensionManager::BeginLoad ( const string & extension)
281417 {
281418 auto extension_name = ExtensionHelper::GetExtensionName(name);
281419
281420 unique_lock<mutex> extension_list_lock(lock);
281421
281422 optional_ptr<ExtensionInfo> info;
281423 auto entry = loaded_extensions_info.find(extension_name);
281424 if (entry == loaded_extensions_info.end()) {
281425 // we don't have an entry yet - create one
281426 auto extension_info = make_uniq<ExtensionInfo>();
281427 info = extension_info.get();
281428 loaded_extensions_info.emplace(extension_name, std::move(extension_info));
281429 } else {
281430 // we already have an entry
281431 if (entry->second->is_loaded) {
281432 // and it is loaded! we are done
281433 return nullptr;
281434 }
281435 // it is not loaded yet - try to load it
281436 info = entry->second.get();
281437 }
281438 extension_list_lock.unlock();
281439
281440 // we have an extension and we want to try to load it - instantiate the load
281441 // we instantiate the ExtensionActiveLoad which also grabs the lock for loading the specific extension
281442 auto result = make_uniq<ExtensionActiveLoad>(db, *info, extension_name);
281443
281444 // we now have a lock for loading the extension
281445 // HOWEVER - another thread might have finished loading in the meantime - double check to avoid a double load
281446 if (info->is_loaded) {
281447 return nullptr;
281448 }
281449 for (auto &callback : ExtensionCallback::Iterate(db)) {
281450 callback->OnBeginExtensionLoad(db, extension_name);
281451 }
281452 // extension is not loaded yet and we are in charge of loading it - return
281453 return result;
281454}

◆ Get() [1/2]

ExtensionManager & duckdb::ExtensionManager::Get ( DatabaseInstance & db)
static
281380 {
281381 return db.GetExtensionManager();
281382}

◆ Get() [2/2]

ExtensionManager & duckdb::ExtensionManager::Get ( ClientContext & context)
static
281384 {
281385 return ExtensionManager::Get(DatabaseInstance::GetDatabase(context));
281386}

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