Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SWMgr Class Reference

SWMgr is the main class of the Sword library. More...

#include <swmgr.h>

List of all members.

Public Methods

 SWMgr (SWConfig *iconfig=0, SWConfig *isysconfig=0, bool autoload=true, SWFilterMgr *filterMgr=0)
 Constructor of SWMgr. More...

 SWMgr (SWFilterMgr *filterMgr)
 SWMgr (const char *iConfigPath, bool autoload=true, SWFilterMgr *filterMgr=0)
virtual ~SWMgr ()
 The destructor of SWMgr. More...

virtual void InstallScan (const char *dir)
 Installs a scan for modules in the directory givan as parameter. More...

virtual void Load ()
 Load the modules. More...

virtual void setGlobalOption (const char *option, const char *value)
 Set a global option Set a global option using the parameters. More...

virtual const char * getGlobalOption (const char *option)
 Gives the value of the given option. More...

virtual const char * getGlobalOptionTip (const char *option)
 Gives a description for the given option. More...

virtual OptionsList getGlobalOptions ()
 A list of all availble options with the currently set values. More...

virtual OptionsList getGlobalOptionValues (const char *option)
virtual signed char setCipherKey (const char *modName, const char *key)
 Sets the cipher key for the given module. More...


Static Public Methods

void findConfig (char *configType, char **prefixPath, char **configPath)

Public Attributes

SWConfigconfig
 The global config object. More...

SWConfigsysconfig
ModMap Modules
 The map of available modules. More...

char * prefixPath
 The path to your Sword directory.

char * configPath

Static Public Attributes

bool debug
 Enable / Disable debug output on runtime Set this to true to get more verbose output of SWMgr at runtime. More...

const char * globalConfPath

Protected Methods

void CreateMods ()
SWModuleCreateMod (string name, string driver, ConfigEntMap &section)
void DeleteMods ()
virtual void init ()
virtual char AddModToConfig (int 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)
 Adds the encoding filters which are defined in "section" to the SWModule object "module". More...

virtual void AddRenderFilters (SWModule *module, ConfigEntMap &section)
 Adds the render filters which are defined in "section" to the SWModule object "module". More...

virtual void AddStripFilters (SWModule *module, ConfigEntMap &section)
 Adds the strip filters which are defined in "section" to the SWModule object "module". More...

virtual void AddRawFilters (SWModule *module, ConfigEntMap &section)
 Adds the raw filters which are defined in "section" to the SWModule object "module". More...


Protected Attributes

SWFilterMgr * filterMgr
SWConfigmyconfig
SWConfigmysysconfig
char configType
FilterMap optionFilters
FilterMap cipherFilters
SWFilter * gbfplain
SWFilter * thmlplain
FilterList cleanupFilters
OptionsList options

Private Methods

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


Detailed Description

SWMgr is the main class of the Sword library.

SWmgr manages the installed modules, the filters and global options like footnotes or strong numbers. The class SWMgr is the most important class of Sword. It is used to manage the installed modules. It also manages the filters (Render-, Strip- and Rawfilters).

To get the SWModule objects of the instalelled modules use Modules for this.

See also:
AddRawFilters(), AddRenderFilters(), AddStripFilters()
Version:
Id:
swmgr.h,v 1.36 2002/01/04 23:36:32 scribe Exp

Definition at line 69 of file swmgr.h.


Constructor & Destructor Documentation

SWMgr::SWMgr SWConfig * iconfig = 0,
SWConfig * isysconfig = 0,
bool autoload = true,
SWFilterMgr * filterMgr = 0
 

Constructor of SWMgr.

Parameters:
iconfig  
isysconfig  
autoload   If this bool is true the constructor starts loading the installed modules. If you reimplemented SWMgr you can set autoload=false to load the modules with your own reimplemented function.
filterMgr   an SWFilterMgr subclass to use to manager filters on modules THIS WILL BE DELETED BY SWMgr

SWMgr::SWMgr SWFilterMgr * filterMgr
 

Parameters:
filterMgr   an SWFilterMgr subclass to use to manager filters on modules THIS WILL BE DELETED BY SWMgr

SWMgr::SWMgr const char * iConfigPath,
bool autoload = true,
SWFilterMgr * filterMgr = 0
 

Parameters:
autoload   If this bool is true the constructor starts loading the installed modules. If you reimplemented SWMgr you can set autoload=false to load the modules with your own reimplemented function.
filterMgr   an SWFilterMgr subclass to use to manager filters on modules THIS WILL BE DELETED BY SWMgr

virtual SWMgr::~SWMgr [virtual]
 

The destructor of SWMgr.

This function cleans up the modules and deletes the created object. Destroy the SWMgr at last object in your application, because otherwise you may experience crashes because the SWModule objects become invalid.


Member Function Documentation

virtual void SWMgr::AddEncodingFilters SWModule * module,
ConfigEntMap & section
[protected, virtual]
 

Adds the encoding filters which are defined in "section" to the SWModule object "module".

Parameters:
module   To this module the encoding filter(s) are added
section   We use this section to get a list of filters we should apply to the module

virtual void SWMgr::AddRawFilters SWModule * module,
ConfigEntMap & section
[protected, virtual]
 

Adds the raw filters which are defined in "section" to the SWModule object "module".

Parameters:
module   To this module the raw filter(s) are added
section   We use this section to get a list of filters we should apply to the module

virtual void SWMgr::AddRenderFilters SWModule * module,
ConfigEntMap & section
[protected, virtual]
 

Adds the render filters which are defined in "section" to the SWModule object "module".

Parameters:
module   To this module the render filter(s) are added
section   We use this section to get a list of filters we should apply to the module

virtual void SWMgr::AddStripFilters SWModule * module,
ConfigEntMap & section
[protected, virtual]
 

Adds the strip filters which are defined in "section" to the SWModule object "module".

Parameters:
module   To this module the strip filter(s) are added
section   We use this section to get a list of filters we should apply to the module

virtual void SWMgr::InstallScan const char * dir [virtual]
 

Installs a scan for modules in the directory givan as parameter.

Parameters:
dir   The directory where new modules should be searched.

virtual void SWMgr::Load [virtual]
 

Load the modules.

Reimplement this function to use your own Load function, for example to use your own filters.

virtual const char* SWMgr::getGlobalOption const char * option [virtual]
 

Gives the value of the given option.

Parameters:
The   option, which should be used to return the value of it
Returns:
The value of the given option

virtual const char* SWMgr::getGlobalOptionTip const char * option [virtual]
 

Gives a description for the given option.

Parameters:
option   The option, which should be used
Returns:
A description of the given option
See also:
setGlobalOption, getGlobalOption, getGlobalOptions

virtual OptionsList SWMgr::getGlobalOptions [virtual]
 

A list of all availble options with the currently set values.

Returns:
This function returns a list of global options.

virtual signed char 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
an key This is the new unlck key we use for te module.

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

Set a global option Set a global option using the parameters.

A global option could be for example footnotes.

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


Member Data Documentation

ModMap SWMgr::Modules
 

The map of available modules.

This map contains thew list of available modules in Sword. Here's an example how to got through the map and how toc ehck for the module type.

 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 170 of file swmgr.h.

SWConfig* SWMgr::config
 

The global config object.

This is the global config object. It contains all items of all modules, so lookups of entries should use this config object. If you want to save a cipher key or other things to the module config file, DO NOT USE this object, because it would corrupt your config files after config->Save().

If you want to write to the modules config file read the informtaion of setCipherKey() for an example of this.

Definition at line 143 of file swmgr.h.

bool SWMgr::debug [static]
 

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

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

Definition at line 128 of file swmgr.h.


The documentation for this class was generated from the following file:
Generated at Tue Jan 22 14:52:49 2002 for The Sword Project by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001