sword::SWMgr Class Reference

SWMgr exposes an installed module set. More...

#include <swmgr.h>

Collaboration diagram for sword::SWMgr:

Collaboration graph
[legend]
List of all members.

Public Member Functions

SWModulegetModule (const char *modName)
 Gets a specific module by name.
const SWModulegetModule (const char *modName) const
 SWMgr (SWConfig *iconfig=0, SWConfig *isysconfig=0, bool autoload=true, SWFilterMgr *filterMgr=0, bool multiMod=false)
 Constructs an instance of SWMgr.
 SWMgr (SWFilterMgr *filterMgr, bool multiMod=false)
 SWMgr (const char *iConfigPath, bool autoload=true, SWFilterMgr *filterMgr=0, bool multiMod=false, bool augmentHome=true)
 
Parameters:
iConfigPath provide a custom path to use for module set location, instead of searching the system for it.

virtual ~SWMgr ()
 The destructor of SWMgr.
virtual void augmentModules (const char *path, bool multiMod=false)
 Adds books from a new path to the library.
void deleteModule (const char *)
virtual void InstallScan (const char *dir)
 Looks for any newly installed module.conf file in the path provided, displays the copyright information to the user, and then copies the module.conf to the main module set's mods.d directory.
virtual signed char Load ()
 Load all modules.
virtual void setGlobalOption (const char *option, const char *value)
 Change the values of global options (e.g.
virtual const char * getGlobalOption (const char *option)
 Get the current value of the given option.
virtual const char * getGlobalOptionTip (const char *option)
 Gets a brief description for the given option.
virtual StringList getGlobalOptions ()
 Gets a list of all available option names.
virtual StringList getGlobalOptionValues (const char *option)
 Gets a list of legal values to which a specific option may be set.
virtual char filterText (const char *filterName, SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 Filters a buffer thru a named filter.
virtual signed char setCipherKey (const char *modName, const char *key)
 Sets the cipher key for the given module.

Static Public Member Functions

static void findConfig (char *configType, char **prefixPath, char **configPath, StringList *augPaths=0, SWConfig *providedSysConf=0)

Public Attributes

SWConfigconfig
SWConfigsysconfig
char * prefixPath
 The path to main module set and locales.
char * configPath
 path to main module set configuration
ModMap Modules
 The map of available modules.

Static Public Attributes

static bool debug
 Enable / Disable debug output at runtime Set this to true to get more verbose output from SWMgr at runtime.
static bool isICU
static const char * globalConfPath

Protected Member Functions

void CreateMods (bool multiMod=false)
SWModuleCreateMod (const char *name, const char *driver, ConfigEntMap &section)
void DeleteMods ()
virtual void init ()
virtual char AddModToConfig (FileDesc *conffd, const char *fname)
virtual void loadConfigDir (const char *ipath)
virtual void AddGlobalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
virtual void AddLocalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
virtual void AddEncodingFilters (SWModule *module, ConfigEntMap &section)
 Called to add appropriate Encoding Filters to a module.
virtual void AddRenderFilters (SWModule *module, ConfigEntMap &section)
 Called to add appropriate Render Filters to a module.
virtual void AddStripFilters (SWModule *module, ConfigEntMap &section)
 Called to add appropriate Strip Filters to a module.
virtual void AddStripFilters (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
virtual void AddRawFilters (SWModule *module, ConfigEntMap &section)
 Called to add appropriate Raw Filters to a module.

Protected Attributes

SWFilterMgrfilterMgr
SWConfigmyconfig
SWConfigmysysconfig
SWConfighomeConfig
char configType
OptionFilterMap optionFilters
FilterMap cipherFilters
SWFiltergbfplain
SWFilterthmlplain
SWFilterosisplain
SWFilterteiplain
SWOptionFiltertransliterator
FilterList cleanupFilters
StringList options
StringList augPaths

Private Member Functions

void commonInit (SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod=false)

Private Attributes

bool mgrModeMultiMod
bool augmentHome

Detailed Description

SWMgr exposes an installed module set.

SWMgr exposes an installed module set and can be asked to configure the desired markup and options which modules will produce.

Version:
Id
swmgr.h 2077 2007-09-14 01:34:37Z scribe

Definition at line 87 of file swmgr.h.


Constructor & Destructor Documentation

sword::SWMgr::SWMgr ( SWConfig iconfig = 0,
SWConfig isysconfig = 0,
bool  autoload = true,
SWFilterMgr filterMgr = 0,
bool  multiMod = false 
)

Constructs an instance of SWMgr.

Parameters:
iconfig manually supply a configuration. If not supplied, SWMgr will look on the system using a complex hierarchical search. See README for detailed specifics.
isysconfig 
autoload whether or not to immediately load modules on construction of this SWMgr. If you reimplemented SWMgr you can set this to false and call SWMgr::Load() after you have completed the contruction and setup of your SWMgr subclass.
filterMgr an SWFilterMgr subclass to use to manager filters on modules SWMgr TAKES OWNERSHIP FOR DELETING THIS OBJECT For example, this will create an SWMgr and cause its modules to produce HTMLHREF formatted output when asked for renderable text:
SWMgr *myMgr = new SWMgr(0, 0, true, new MarkupFilterMgr(FMT_HTMLHREF));

virtual sword::SWMgr::~SWMgr (  )  [virtual]

The destructor of SWMgr.

This function cleans up the modules and deletes the created object. Destroying the SWMgr causes all retrieved SWModule object to be invalid, so be sure to destroy only when retrieved objects are no longer needed.


Member Function Documentation

virtual void sword::SWMgr::AddEncodingFilters ( SWModule module,
ConfigEntMap section 
) [protected, virtual]

Called to add appropriate Encoding Filters to a module.

Override to do special actions, if desired. See the module.conf Encoding= entry.

Parameters:
module module to which to add Encoding Filters
section configuration information from module.conf

virtual void sword::SWMgr::AddRenderFilters ( SWModule module,
ConfigEntMap section 
) [protected, virtual]

Called to add appropriate Render Filters to a module.

Override to do special actions, if desired. See the module.conf SourceType= entry.

Parameters:
module module to which to add Render Filters
section configuration information from module.conf

virtual void sword::SWMgr::AddStripFilters ( SWModule module,
ConfigEntMap section 
) [protected, virtual]

Called to add appropriate Strip Filters to a module.

Override to do special actions, if desired. See the module.conf SourceType= entry.

Parameters:
module module to which to add Strip Filters
section configuration information from module.conf

virtual void sword::SWMgr::AddRawFilters ( SWModule module,
ConfigEntMap section 
) [protected, virtual]

Called to add appropriate Raw Filters to a module.

Override to do special actions, if desired. See the module.conf CipherKey= entry.

Parameters:
module module to which to add Raw Filters
section configuration information from module.conf

SWModule* sword::SWMgr::getModule ( const char *  modName  )  [inline]

Gets a specific module by name.

e.g. SWModule *kjv = myManager.getModule("KJV");

Parameters:
modName the name of the module to retrieve
Returns:
the module, if found, otherwise 0

Definition at line 211 of file swmgr.h.

virtual void sword::SWMgr::augmentModules ( const char *  path,
bool  multiMod = false 
) [virtual]

Adds books from a new path to the library.

Parameters:
path the path in which to search for books
multiMod whether or not to keep multiple copies of the same book if found in different paths default - false, uses last found version of the book

virtual void sword::SWMgr::InstallScan ( const char *  dir  )  [virtual]

Looks for any newly installed module.conf file in the path provided, displays the copyright information to the user, and then copies the module.conf to the main module set's mods.d directory.

Parameters:
dir where to search for new modules

virtual signed char sword::SWMgr::Load (  )  [virtual]

Load all modules.

Should only be manually called if SWMgr was constructed without autoload; otherwise, this will be called on SWMgr construction Reimplement this function to supply special functionality when modules are initially loaded.

virtual void sword::SWMgr::setGlobalOption ( const char *  option,
const char *  value 
) [virtual]

Change the values of global options (e.g.

Footnotes, Strong's Number, etc.)

Parameters:
option The name of the option, for which you want to change the value. Well known and often used values are "Footnotes" or "Strong's Numbers"
value new value. Common values are "On" and "Off"

virtual const char* sword::SWMgr::getGlobalOption ( const char *  option  )  [virtual]

Get the current value of the given option.

Parameters:
option the name of the option, who's value is desired
Returns:
the value of the given option

virtual const char* sword::SWMgr::getGlobalOptionTip ( const char *  option  )  [virtual]

Gets a brief description for the given option.

Parameters:
option the name of the option, who's tip is desired
Returns:
description text
See also:
setGlobalOption, getGlobalOption, getGlobalOptions

virtual StringList sword::SWMgr::getGlobalOptions (  )  [virtual]

Gets a list of all available option names.

Returns:
list of option names

virtual StringList sword::SWMgr::getGlobalOptionValues ( const char *  option  )  [virtual]

Gets a list of legal values to which a specific option may be set.

Parameters:
option the name of the option, who's legal values are desired
Returns:
a list of legal values for the given option

virtual char sword::SWMgr::filterText ( const char *  filterName,
SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
) [virtual]

Filters a buffer thru a named filter.

Parameters:
filterName 
text buffer to filter
key context key if filter needs this for processing
module context module if filter needs this for processing
Returns:
error status

virtual signed char sword::SWMgr::setCipherKey ( const char *  modName,
const char *  key 
) [virtual]

Sets the cipher key for the given module.

This function updates the key at runtime, but it does not write to the config file. To write the new unlock key to the config file use code like this:

 SectionMap::iterator section;
 ConfigEntMap::iterator entry;
 DIR *dir = opendir(configPath);
 struct dirent *ent;
 char* modFile;
 if (dir) {    // find and update .conf file
   rewinddir(dir);
   while ((ent = readdir(dir)))
   {
     if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, "..")))
     {
       modFile = m_backend->configPath;
       modFile += "/";
       modFile += ent->d_name;
       SWConfig *myConfig = new SWConfig( modFile );
       section = myConfig->Sections.find( m_module->Name() );
       if ( section != myConfig->Sections.end() )
       {
         entry = section->second.find("CipherKey");
         if (entry != section->second.end())
         {
           entry->second = unlockKey;//set cipher key
           myConfig->Save();//save config file
         }
       }
       delete myConfig;
     }
   }
 }
 closedir(dir);

Parameters:
modName For this module we change the unlockKey
key This is the new unlck key we use for te module.


Member Data Documentation

bool sword::SWMgr::debug [static]

Enable / Disable debug output at runtime Set this to true to get more verbose output from SWMgr at runtime.

Set it to false to get no debug output. The default is "false".

Definition at line 162 of file swmgr.h.

ModMap sword::SWMgr::Modules

The map of available modules.

This map exposes the installed modules. Here's an example how to iterate over the map and check the module type of each module.

 ModMap::iterator it;
 SWModule *curMod = 0;

 for (it = Modules.begin(); it != Modules.end(); it++) {
      curMod = (*it).second;
      if (!strcmp(curMod->Type(), "Biblical Texts")) {
           // do something with curMod
      }
      else if (!strcmp(curMod->Type(), "Commentaries")) {
           // do something with curMod
      }
      else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
           // do something with curMod
      }
 }

Definition at line 205 of file swmgr.h.


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