#include <swmgr.h>
Collaboration diagram for sword::SWMgr:
Public Member Functions | |
SWModule * | getModule (const char *modName) |
SWMgr (SWConfig *iconfig=0, SWConfig *isysconfig=0, bool autoload=true, SWFilterMgr *filterMgr=0) | |
Constructor of SWMgr. | |
SWMgr (SWFilterMgr *filterMgr) | |
SWMgr (const char *iConfigPath, bool autoload=true, SWFilterMgr *filterMgr=0) | |
virtual | ~SWMgr () |
The destructor of SWMgr. | |
virtual void | InstallScan (const char *dir) |
Installs a scan for modules in the directory givan as parameter. | |
virtual signed char | Load () |
Load the modules. | |
virtual void | setGlobalOption (const char *option, const char *value) |
Set a global option Set a global option using the parameters. | |
virtual const char * | getGlobalOption (const char *option) |
Gives the value of the given option. | |
virtual const char * | getGlobalOptionTip (const char *option) |
Gives a description for the given option. | |
virtual OptionsList | getGlobalOptions () |
A list of all availble options with the currently set values. | |
virtual OptionsList | getGlobalOptionValues (const char *option) |
virtual signed char | setCipherKey (const char *modName, const char *key) |
Sets the cipher key for the given module. | |
Static Public Member Functions | |
void | findConfig (char *configType, char **prefixPath, char **configPath, std::list< std::string > *augPaths=0) |
Public Attributes | |
SWConfig * | config |
The global config object. | |
SWConfig * | sysconfig |
ModMap | Modules |
The map of available modules. | |
char * | prefixPath |
The path to your Sword directory. | |
char * | configPath |
Static Public Attributes | |
bool | debug = false |
Enable / Disable debug output on runtime Set this to true to get more verbose output of SWMgr at runtime. | |
bool | isICU = false |
const char * | globalConfPath = "/etc/sword.conf:/usr/local/etc/sword.conf" |
Protected Member Functions | |
void | CreateMods () |
SWModule * | CreateMod (std::string name, std::string driver, ConfigEntMap §ion) |
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 §ion, ConfigEntMap::iterator start, ConfigEntMap::iterator end) |
virtual void | AddLocalOptions (SWModule *module, ConfigEntMap §ion, ConfigEntMap::iterator start, ConfigEntMap::iterator end) |
virtual void | AddEncodingFilters (SWModule *module, ConfigEntMap §ion) |
Adds the encoding filters which are defined in "section" to the SWModule object "module". | |
virtual void | AddRenderFilters (SWModule *module, ConfigEntMap §ion) |
Adds the render filters which are defined in "section" to the SWModule object "module". | |
virtual void | AddStripFilters (SWModule *module, ConfigEntMap §ion) |
Adds the strip filters which are defined in "section" to the SWModule object "module". | |
virtual void | AddRawFilters (SWModule *module, ConfigEntMap §ion) |
Adds the raw filters which are defined in "section" to the SWModule object "module". | |
virtual void | augmentModules (const char *ipath) |
Protected Attributes | |
SWFilterMgr * | filterMgr |
SWConfig * | myconfig |
SWConfig * | mysysconfig |
SWConfig * | homeConfig |
char | configType |
FilterMap | optionFilters |
FilterMap | cipherFilters |
SWFilter * | gbfplain |
SWFilter * | thmlplain |
SWFilter * | osisplain |
SWFilter * | transliterator |
FilterList | cleanupFilters |
OptionsList | options |
std::list< std::string > | augPaths |
Private Member Functions | |
void | commonInit (SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr) |
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.
|
Constructor of SWMgr.
|
|
|
|
|
|
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. |
|
Adds the encoding filters which are defined in "section" to the SWModule object "module".
|
|
Adds the raw filters which are defined in "section" to the SWModule object "module".
|
|
Adds the render filters which are defined in "section" to the SWModule object "module".
|
|
Adds the strip filters which are defined in "section" to the SWModule object "module".
|
|
Gives the value of the given option.
|
|
A list of all availble options with the currently set values.
|
|
Gives a description for the given option.
|
|
Installs a scan for modules in the directory givan as parameter.
|
|
Load the modules. Reimplement this function to use your own Load function, for example to use your own filters. |
|
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);
|
|
Set a global option Set a global option using the parameters. A global option could be for example footnotes.
|
|
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. |
|
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". |
|
The map of available modules. This map contains the 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 } } |
|
The path to your Sword directory.
|