The Sword Project: sword::SWMgr Class Reference |
#include <swmgr.h>
Collaboration diagram for sword::SWMgr:
Public Member Functions | ||||
SWModule * | getModule (const char *modName) | |||
Gets a specific module by name. | ||||
const SWModule * | getModule (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) | ||||
| ||||
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 | ||||
SWConfig * | config | |||
SWConfig * | sysconfig | |||
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) | |||
SWModule * | CreateMod (const char *name, const char *driver, ConfigEntMap §ion) | |||
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 §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) | |||
Called to add appropriate Encoding Filters to a module. | ||||
virtual void | AddRenderFilters (SWModule *module, ConfigEntMap §ion) | |||
Called to add appropriate Render Filters to a module. | ||||
virtual void | AddStripFilters (SWModule *module, ConfigEntMap §ion) | |||
Called to add appropriate Strip Filters to a module. | ||||
virtual void | AddStripFilters (SWModule *module, ConfigEntMap §ion, ConfigEntMap::iterator start, ConfigEntMap::iterator end) | |||
virtual void | AddRawFilters (SWModule *module, ConfigEntMap §ion) | |||
Called to add appropriate Raw Filters to a module. | ||||
Protected Attributes | ||||
SWFilterMgr * | filterMgr | |||
SWConfig * | myconfig | |||
SWConfig * | mysysconfig | |||
SWConfig * | homeConfig | |||
char | configType | |||
OptionFilterMap | optionFilters | |||
FilterMap | cipherFilters | |||
SWFilter * | gbfplain | |||
SWFilter * | thmlplain | |||
SWFilter * | osisplain | |||
SWFilter * | teiplain | |||
SWOptionFilter * | transliterator | |||
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 |
SWMgr exposes an installed module set and can be asked to configure the desired markup and options which modules will produce.
Definition at line 87 of file swmgr.h.
sword::SWMgr::SWMgr | ( | SWConfig * | iconfig = 0 , |
|
SWConfig * | isysconfig = 0 , |
|||
bool | autoload = true , |
|||
SWFilterMgr * | filterMgr = 0 , |
|||
bool | multiMod = false | |||
) |
Constructs an instance of SWMgr.
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: |
virtual sword::SWMgr::~SWMgr | ( | ) | [virtual] |
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.
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.
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.
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.
module | module to which to add Raw Filters | |
section | configuration information from module.conf |
SWModule* sword::SWMgr::getModule | ( | const char * | modName | ) | [inline] |
virtual void sword::SWMgr::augmentModules | ( | const char * | path, | |
bool | multiMod = false | |||
) | [virtual] |
Adds books from a new path to the library.
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.
dir | where to search for new modules |
virtual signed char sword::SWMgr::Load | ( | ) | [virtual] |
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.)
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.
option | the name of the option, who's value is desired |
virtual const char* sword::SWMgr::getGlobalOptionTip | ( | const char * | option | ) | [virtual] |
Gets a brief description for the given option.
option | the name of the option, who's tip is desired |
virtual StringList sword::SWMgr::getGlobalOptions | ( | ) | [virtual] |
Gets a list of all available 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.
option | the name of the option, who's legal values are desired |
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.
filterName | ||
text | buffer to filter | |
key | context key if filter needs this for processing | |
module | context module if filter needs this for processing |
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);
modName | For this module we change the unlockKey | |
key | This is the new unlck key we use for te module. |
bool sword::SWMgr::debug [static] |
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 } }
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |