diff --git a/modest/cpp/db/modest/ModuleLibrary.cpp b/modest/cpp/db/modest/ModuleLibrary.cpp index 6688f13c..27dd3776 100644 --- a/modest/cpp/db/modest/ModuleLibrary.cpp +++ b/modest/cpp/db/modest/ModuleLibrary.cpp @@ -32,9 +32,9 @@ Module* ModuleLibrary::findModule(const char* name) return rval; } -bool ModuleLibrary::loadModule(const char* filename) +Module* ModuleLibrary::loadModule(const char* filename) { - bool rval = false; + Module* rval = NULL; lock(); { @@ -52,7 +52,7 @@ bool ModuleLibrary::loadModule(const char* filename) // add Module to the map and list mModules[mi->module->getId().name] = mi; mLoadOrder.push_back(mi->module->getId().name); - rval = true; + rval = mi->module; } else { @@ -137,6 +137,20 @@ void ModuleLibrary::unloadAllModules() } } +Module* ModuleLibrary::getModule(const char* name) +{ + Module* rval = NULL; + + lock(); + { + // find Module + rval = findModule(name); + } + unlock(); + + return rval; +} + const ModuleId* ModuleLibrary::getModuleId(const char* name) { const ModuleId* rval = NULL; diff --git a/modest/cpp/db/modest/ModuleLibrary.h b/modest/cpp/db/modest/ModuleLibrary.h index 58c795e2..5c90d338 100644 --- a/modest/cpp/db/modest/ModuleLibrary.h +++ b/modest/cpp/db/modest/ModuleLibrary.h @@ -82,6 +82,10 @@ class ModuleLibrary : public virtual db::rt::Object /** * Finds a loaded Module by its name. + * + * @param name the name of the Module. + * + * @return the Module or NULL if none exists by the given name. */ Module* findModule(const char* name); @@ -103,9 +107,9 @@ class ModuleLibrary : public virtual db::rt::Object * * @param filename the name of the file where the Module resides. * - * @return true if the Module was loaded, false if not. + * @return the Module, if it was loaded, NULL if not. */ - virtual bool loadModule(const char* filename); + virtual Module* loadModule(const char* filename); /** * Unloads a Module from this ModuleLibrary, if it is loaded. @@ -120,9 +124,20 @@ class ModuleLibrary : public virtual db::rt::Object */ virtual void unloadAllModules(); + /** + * Gets a Module by its name. + * + * @param name the name of the Module. + * + * @return the Module or NULL if it does not exist. + */ + virtual Module* getModule(const char* name); + /** * Gets the ModuleId for the Module with the given name. * + * @param name the name of the Module to get the ID for. + * * @return the ModuleId for the Module with the given name or NULL if one * does not exist. */