The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swmgr.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * swmgr.h - class SWMgr: used to interact with an install
4  * base of SWORD modules.
5  *
6  * $Id: swmgr.h 3820 2020-10-24 20:27:30Z scribe $
7  *
8  * Copyright 1997-2014 CrossWire Bible Society (http://www.crosswire.org)
9  * CrossWire Bible Society
10  * P. O. Box 2528
11  * Tempe, AZ 85280-2528
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU General Public License as published by the
15  * Free Software Foundation version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  */
23 
57 #ifndef SWMGR_H
58 #define SWMGR_H
59 
60 #include <map>
61 #include <list>
62 #include <swbuf.h>
63 #include <swconfig.h>
64 
65 #include <defs.h>
66 
68 
69 class SWModule;
70 class SWFilter;
71 class SWOptionFilter;
72 class SWFilterMgr;
73 class SWBuf;
74 class SWKey;
75 
76 typedef std::map < SWBuf, SWModule *, std::less < SWBuf > >ModMap;
77 typedef std::map < SWBuf, SWFilter * >FilterMap;
78 typedef std::map < SWBuf, SWOptionFilter * >OptionFilterMap;
79 typedef std::list < SWBuf >StringList;
80 typedef std::list < SWFilter* >FilterList;
81 typedef std::list < SWOptionFilter* >OptionFilterList;
82 
83 class FileDesc;
84 class SWOptionFilter;
85 
94 private:
98  void commonInit(SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod = false);
99 
100 protected:
101  SWFilterMgr *filterMgr; //made protected because because BibleTime needs it
102  SWConfig *myconfig; //made protected because because BibleTime needs it
108  SWDEPRECATED void CreateMods(bool multiMod = false) { createAllModules(multiMod); };
112  SWDEPRECATED void DeleteMods() { deleteAllModules(); }
113  char configType; // 0 = file; 1 = directory
135  virtual void createAllModules(bool multiMod = false);
141  virtual void deleteAllModules();
142 
148  virtual SWModule *createModule(const char *name, const char *driver, ConfigEntMap &section);
149 
154  virtual void init();
155 
156 
160  SWDEPRECATED virtual void AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) { addGlobalOptionFilters(module, section); }
176  virtual void addGlobalOptionFilters(SWModule *module, ConfigEntMap &section);
177 
181  SWDEPRECATED virtual void AddLocalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) { addLocalOptionFilters(module, section); }
191  virtual void addLocalOptionFilters(SWModule *module, ConfigEntMap &section);
192 
196  SWDEPRECATED virtual void AddEncodingFilters(SWModule *module, ConfigEntMap &section) { addEncodingFilters(module, section); }
204  virtual void addEncodingFilters(SWModule *module, ConfigEntMap &section);
205 
209  SWDEPRECATED virtual void AddRenderFilters(SWModule *module, ConfigEntMap &section) { addRenderFilters(module, section); }
219  virtual void addRenderFilters(SWModule *module, ConfigEntMap &section);
220 
224  SWDEPRECATED virtual void AddStripFilters(SWModule *module, ConfigEntMap &section) { addStripFilters(module, section); }
233  virtual void addStripFilters(SWModule *module, ConfigEntMap &section);
234 
238  SWDEPRECATED virtual void AddStripFilters(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) { addLocalStripFilters(module, section); }
246  virtual void addLocalStripFilters(SWModule *module, ConfigEntMap &section);
247 
251  SWDEPRECATED virtual void AddRawFilters(SWModule *module, ConfigEntMap &section) { addRawFilters(module, section); }
261  virtual void addRawFilters(SWModule *module, ConfigEntMap &section);
262 
263 
264  // still to be normalized below ...
265  //
267  virtual char addModToConfig(FileDesc *conffd, const char *fname);
268  virtual void loadConfigDir(const char *ipath);
269 
270 public:
271 
272  // constants which represent module types used in SWModule::getType
273  static const char *MODTYPE_BIBLES;
274  static const char *MODTYPE_COMMENTARIES;
275  static const char *MODTYPE_LEXDICTS;
276  static const char *MODTYPE_GENBOOKS;
277  static const char *MODTYPE_DAILYDEVOS;
278 
279 
280  static bool isICU;
281  static const char *globalConfPath;
282 
286  SWDEPRECATED static SWBuf getHomeDir();
287 
291  static void findConfig(char *configType, char **prefixPath, char **configPath, StringList *augPaths = 0, SWConfig **providedSysConf = 0);
292 
303 
309 
312  char *prefixPath;
313 
316  char *configPath;
317 
318 
323 
347  ModMap &getModules();
348  const ModMap &getModules() const { return const_cast<SWMgr *>(this)->getModules(); }
349 
353  ModMap &getUtilModules();
354  const ModMap &getUtilModules() const { return const_cast<SWMgr *>(this)->getUtilModules(); }
355 
360  SWModule *getModule(const char *modName) {
361  ModMap::iterator it = getModules().find(modName);
362  if (it == getModules().end()) it = getUtilModules().find(modName);
363  return ((it != getUtilModules().end()) ? it->second : 0);
364  }
365  const SWModule *getModule(const char *modName) const {
366  ModMap::const_iterator it = getModules().find(modName);
367  if (it == getModules().end()) it = getUtilModules().find(modName);
368  return ((it != getUtilModules().end()) ? it->second : 0);
369  }
370 
371 
387  SWMgr(SWConfig *iconfig = 0, SWConfig *isysconfig = 0, bool autoload = true, SWFilterMgr *filterMgr = 0, bool multiMod = false);
388 
391  SWMgr(SWFilterMgr *filterMgr, bool multiMod = false);
392 
397  SWMgr(const char *iConfigPath, bool autoload = true, SWFilterMgr *filterMgr = 0, bool multiMod = false, bool augmentHome = true);
398 
404  virtual ~SWMgr();
405 
412  virtual void augmentModules(const char *path, bool multiMod = false);
413 
414  void deleteModule(const char *);
415 
421  virtual void InstallScan(const char *dir);
422 
426  SWDEPRECATED virtual signed char Load() { return load(); }
436  virtual signed char load();
437 
443  virtual void setGlobalOption(const char *option, const char *value);
444 
449  virtual const char *getGlobalOption(const char *option);
450 
456  virtual const char *getGlobalOptionTip(const char *option);
457 
461  virtual StringList getGlobalOptions();
462 
468  virtual StringList getGlobalOptionValues(const char *option);
469 
477  virtual char filterText(const char *filterName, SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
478 
530  virtual signed char setCipherKey(const char *modName, const char *key);
531 };
532 
534 #endif
SWOptionFilter * transliterator
Definition: swmgr.h:120
#define SWORD_NAMESPACE_START
Definition: defs.h:39
Definition: swmgr.h:93
Definition: swbuf.h:47
virtual SWDEPRECATED void AddEncodingFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.h:196
virtual SWDEPRECATED void AddRawFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.h:251
SWDEPRECATED void DeleteMods()
Definition: swmgr.h:112
static const char * MODTYPE_GENBOOKS
Definition: swmgr.h:276
#define SWDLLEXPORT
Definition: defs.h:171
char configType
Definition: swmgr.h:113
std::map< SWBuf, SWOptionFilter * > OptionFilterMap
Definition: swmgr.h:78
static bool isICU
Definition: swmgr.h:280
ModMap Modules
Definition: swmgr.h:322
std::list< SWOptionFilter * > OptionFilterList
Definition: swmgr.h:81
SWText * module
Definition: osis2mod.cpp:105
static const char * MODTYPE_LEXDICTS
Definition: swmgr.h:275
char * prefixPath
Definition: swmgr.h:312
SWDEPRECATED void CreateMods(bool multiMod=false)
Definition: swmgr.h:108
virtual SWDEPRECATED void AddStripFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.h:224
SWFilter * gbfplain
Definition: swmgr.h:116
#define SWDEPRECATED
Definition: defs.h:174
ModMap utilModules
Definition: swmgr.h:95
FilterMap extraFilters
Definition: swmgr.h:122
virtual SWDEPRECATED void AddRenderFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.h:209
virtual SWDEPRECATED signed char Load()
Definition: swmgr.h:426
static const char * MODTYPE_BIBLES
Definition: swmgr.h:273
SWModule * getModule(const char *modName)
Definition: swmgr.h:360
SWConfig * config
Definition: swmgr.h:302
OptionFilterMap optionFilters
Definition: swmgr.h:114
void init()
Definition: installmgr.cpp:164
std::map< SWBuf, SWFilter * > FilterMap
Definition: swmgr.h:77
const ModMap & getUtilModules() const
Definition: swmgr.h:354
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
virtual SWDEPRECATED void AddLocalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
Definition: swmgr.h:181
FilterMap cipherFilters
Definition: swmgr.h:115
std::list< SWFilter * > FilterList
Definition: swmgr.h:80
static const char * MODTYPE_COMMENTARIES
Definition: swmgr.h:274
bool mgrModeMultiMod
Definition: swmgr.h:96
StringList augPaths
Definition: swmgr.h:266
FilterList cleanupFilters
Definition: swmgr.h:121
std::map< SWBuf, SWModule *, std::less< SWBuf > > ModMap
Definition: swmgr.h:74
SWConfig * myconfig
Definition: swmgr.h:102
SWConfig * sysConfig
Definition: swmgr.h:308
StringList options
Definition: swmgr.h:123
virtual SWDEPRECATED void AddStripFilters(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
Definition: swmgr.h:238
static const char * MODTYPE_DAILYDEVOS
Definition: swmgr.h:277
SWFilter * osisplain
Definition: swmgr.h:118
SWFilter * teiplain
Definition: swmgr.h:119
const ModMap & getModules() const
Definition: swmgr.h:348
const SWModule * getModule(const char *modName) const
Definition: swmgr.h:365
SWORD_NAMESPACE_START typedef multimapwithdefault< SWBuf, SWBuf, std::less< SWBuf > > ConfigEntMap
Definition: swconfig.h:35
SWConfig * mysysconfig
Definition: swmgr.h:103
bool augmentHome
Definition: swmgr.h:97
SWConfig * homeConfig
Definition: swmgr.h:104
#define SWORD_NAMESPACE_END
Definition: defs.h:40
Definition: swkey.h:77
virtual SWDEPRECATED void AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
Definition: swmgr.h:160
SWFilter * thmlplain
Definition: swmgr.h:117
static const char * globalConfPath
Definition: swmgr.h:281
char * configPath
Definition: swmgr.h:316
SWFilterMgr * filterMgr
Definition: swmgr.h:101