Skip to content

Commit

Permalink
Changed loadModule() method to return a Module* instead of a boolean
Browse files Browse the repository at this point in the history
so that once a module is loaded, its name, id, etc can be determined
if it wasn't known previously.
  • Loading branch information
dlongley committed Oct 17, 2007
1 parent 70ca38a commit 04cc483
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
20 changes: 17 additions & 3 deletions modest/cpp/db/modest/ModuleLibrary.cpp
Expand Up @@ -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();
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 17 additions & 2 deletions modest/cpp/db/modest/ModuleLibrary.h
Expand Up @@ -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);

Expand All @@ -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.
Expand All @@ -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.
*/
Expand Down

0 comments on commit 04cc483

Please sign in to comment.