ResourceManager
is used to manage the UIMACPP resources.
The class ResourceManager
is a singleton. For example, there can only be one instance of the class per process. The first argument cpszInstance
defines the instance name of this instance.
The second argument cpszProductPrefix
is optional and defines the product prefix. Both arguments are no longer used.
foo(const TCHAR * cpszInstance) { // first create an instance of the UIMACPP resource manager ResourceManager & rclUimaResourceMgr = ResourceManager::createInstance(cpszInstance); if(rclUimaResourceMgr.getLastErrorId() != UIMA_ERR_NONE) { ErrorMessage clMessage( rclUimaResourceMgr.getLastErrorId() ); cout << clMessage << endl; } }
ResourceManager
is deleted automatically. Static Functions | |
static ResourceManager & | createInstance (const TCHAR *cpszInstance, const TCHAR *cpszProductPrefix=0) |
Returns a pointer to the singleton instance of ResourceManager for this process and passes the instance key to it. | |
static ResourceManager & | getInstance (void) |
Returns a pointer to the singleton instance of ResourceManager for this process. | |
static bool | hasInstance (void) |
Return TRUE, if the resource manager has been initialized. | |
static void | deleteInstance (void) |
Deletes the resource manager instance. | |
static icu::UnicodeString | resolveFilename (icu::UnicodeString const &filename, icu::UnicodeString const &lastFilename) |
util::Filename const * | getStreamHandlerForURIScheme (std::string uriScheme) |
Look up the streamhandler dll that supports the URI scheme. | |
void | registerLogger (Logger *) |
Register Logger. | |
void | unregisterLogger (Logger *) |
unregister this logger. | |
std::vector< Logger * > & | getLoggers () |
Public Member Functions | |
Properties | |
TyErrorId | getLastErrorId (void) const |
Returns the last error that occurred. | |
const util::Location & | getLocationWork (void) const |
Returns the location used for storing temporary work files. | |
const util::Location & | getLocationData (void) const |
Returns the location used for storing data files. | |
bool | isSchemaAvailable (void) |
Returns the location used to find the schema definition file used for schema validation when parsing descriptors. | |
TCHAR const * | getSchemaInfo (void) |
void | enableSchemaValidation (bool aEnable) |
bool | doSchemaValidation (void) |
LogStream::EnEntryType | getLoggingLevel () |
get the current logging level | |
void | setLoggingLevel (LogStream::EnEntryType level) |
set the current minimum logging level | |
void | setupJavaLogging (void *jniEnv) |
store handle to java env and handle to java log method | |
bool | isJavaLoggingEnabled () |
true is java logging is setup | |
uima::LogFacility & | getLogger () |
returns handle to the framework logger | |
util::DllProcLoaderFile * | requestAnnotatorFile (const util::Filename &crclFilename) |
Returns an AnnotatorFile from the pool of AnnotatorFiles with the specified filename. | |
ResourceABase const * | getResource (uima::Language const &crLang, ResourceFactoryABase const &crFactory, ErrorInfo &) |
Convenience function. | |
ResourceABase const * | getResource (icu::UnicodeString const &crKey, ResourceFactoryABase const &crFactory, ErrorInfo &) |
Main method to create/access resources. | |
void | registerFactory (icu::UnicodeString const &crKind, ResourceFactoryABase &crFactory) |
Register a factory for a given kind of ressource. | |
void | deRegisterFactory (icu::UnicodeString const &crKind, ResourceFactoryABase &crFactory) |
Deregister a factory for a given kind of ressource. | |
ResourceABase const * | getResource (icu::UnicodeString const &crKey, icu::UnicodeString const &crKind, ErrorInfo &) |
get or create a ressource of a given kind and key using a factory registered earlier using registerFactory | |
Miscellaneous | |
void | setNewLocationWork (const util::Location &crclLocation) |
Sets a new location to store temporary work files. | |
void | setNewLocationData (const util::Location &crclLocation) |
Sets a new location to store data files. | |
Static Public Member Functions | |
static bool | createFilenameForLanguage (Language &rclLanguage, const TCHAR *cpszExtension, bool bUseAlternateTerritories, const util::Location &crclDirToUse, util::Filename &rclFilename) |
Creates a filename for a resource file based on the specified language and the specified filename extension. |
static bool uima::ResourceManager::createFilenameForLanguage | ( | Language & | rclLanguage, | |
const TCHAR * | cpszExtension, | |||
bool | bUseAlternateTerritories, | |||
const util::Location & | crclDirToUse, | |||
util::Filename & | rclFilename | |||
) | [static] |
Creates a filename for a resource file based on the specified language and the specified filename extension.
Returns TRUE, if a file with this filename exists.
Example: language is "en-us" and extension is ".tsw" filename will be en-us.tsw
If bUseAlternateTerritories
is enabled, another attempt is made, only using the language name without the territory.
Example: language is "en" and the extension is ".tsw". The filename could also be en-uk.tsw
TyErrorId uima::ResourceManager::getLastErrorId | ( | void | ) | const [inline] |
Returns the last error that occurred.
const util::Location& uima::ResourceManager::getLocationWork | ( | void | ) | const |
Returns the location used for storing temporary work files.
const util::Location& uima::ResourceManager::getLocationData | ( | void | ) | const |
Returns the location used for storing data files.
bool uima::ResourceManager::isSchemaAvailable | ( | void | ) |
Returns the location used to find the schema definition file used for schema validation when parsing descriptors.
TCHAR const* uima::ResourceManager::getSchemaInfo | ( | void | ) |
void uima::ResourceManager::enableSchemaValidation | ( | bool | aEnable | ) |
bool uima::ResourceManager::doSchemaValidation | ( | void | ) |
LogStream::EnEntryType uima::ResourceManager::getLoggingLevel | ( | ) |
get the current logging level
void uima::ResourceManager::setLoggingLevel | ( | LogStream::EnEntryType | level | ) |
set the current minimum logging level
void uima::ResourceManager::setupJavaLogging | ( | void * | jniEnv | ) |
store handle to java env and handle to java log method
bool uima::ResourceManager::isJavaLoggingEnabled | ( | ) |
true is java logging is setup
uima::LogFacility& uima::ResourceManager::getLogger | ( | ) |
returns handle to the framework logger
util::DllProcLoaderFile* uima::ResourceManager::requestAnnotatorFile | ( | const util::Filename & | crclFilename | ) |
Returns an AnnotatorFile from the pool of AnnotatorFiles with the specified filename.
ResourceABase const* uima::ResourceManager::getResource | ( | uima::Language const & | crLang, | |
ResourceFactoryABase const & | crFactory, | |||
ErrorInfo & | ||||
) |
Convenience function.
Extracts the string from crLang and calls getResource().
ResourceABase const* uima::ResourceManager::getResource | ( | icu::UnicodeString const & | crKey, | |
ResourceFactoryABase const & | crFactory, | |||
ErrorInfo & | ||||
) |
Main method to create/access resources.
If a resource with the same key and kind as the factory already exists, it is returned, otherwise a new one is created.
void uima::ResourceManager::registerFactory | ( | icu::UnicodeString const & | crKind, | |
ResourceFactoryABase & | crFactory | |||
) |
Register a factory for a given kind of ressource.
Only after registering a factory for a kind a resource can be acquired using the getResource() overload below
void uima::ResourceManager::deRegisterFactory | ( | icu::UnicodeString const & | crKind, | |
ResourceFactoryABase & | crFactory | |||
) |
Deregister a factory for a given kind of ressource.
ResourceABase const* uima::ResourceManager::getResource | ( | icu::UnicodeString const & | crKey, | |
icu::UnicodeString const & | crKind, | |||
ErrorInfo & | ||||
) |
get or create a ressource of a given kind and key using a factory registered earlier using registerFactory
void uima::ResourceManager::setNewLocationWork | ( | const util::Location & | crclLocation | ) |
Sets a new location to store temporary work files.
void uima::ResourceManager::setNewLocationData | ( | const util::Location & | crclLocation | ) |
Sets a new location to store data files.
static ResourceManager& uima::ResourceManager::createInstance | ( | const TCHAR * | cpszInstance, | |
const TCHAR * | cpszProductPrefix = 0 | |||
) | [static] |
Returns a pointer to the singleton instance of ResourceManager for this process and passes the instance key to it.
Note: This function must be called before any calls to static method ResourceManager::getInstance()/0.
static ResourceManager& uima::ResourceManager::getInstance | ( | void | ) | [static] |
Returns a pointer to the singleton instance of ResourceManager for this process.
static bool uima::ResourceManager::hasInstance | ( | void | ) | [static] |
Return TRUE, if the resource manager has been initialized.
static void uima::ResourceManager::deleteInstance | ( | void | ) | [static] |
Deletes the resource manager instance.
util::Filename const* uima::ResourceManager::getStreamHandlerForURIScheme | ( | std::string | uriScheme | ) |
Look up the streamhandler dll that supports the URI scheme.
uriScheme | - eg file, sdo. |
static icu::UnicodeString uima::ResourceManager::resolveFilename | ( | icu::UnicodeString const & | filename, | |
icu::UnicodeString const & | lastFilename | |||
) | [static] |
Referenced by uima::ImportDescription::findAbsoluteUrl().
void uima::ResourceManager::registerLogger | ( | Logger * | ) |
Register Logger.
Caller owns the logger instance.
void uima::ResourceManager::unregisterLogger | ( | Logger * | ) |
unregister this logger.
Caller owns logger instance.
std::vector<Logger*>& uima::ResourceManager::getLoggers | ( | ) |