ot::auxil
class FileMessageFactory
#include "ot/auxil/FileMessageFactory.h"
An implementation of the MessageFactory interface which loads error and and information messages from a local file.
Whenever the OpenTop classes need to produce an exception, error or information message, they make a call to System::GetSysMessage() which, in turn, calls System::GetMessageFactory() to locate an application-supplied MessageFactory object. An application can supply a MessageFactory by calling System::SetMessageFactory() during initialization.
If a MessageFactory object is returned, the getMessage() method is called to give the factory an opportunity to supply a custom message. If the factory is unable to supply the message text, then the system uses a default value instead.
This implementation of the interface loads messages from a file. The loading of messages is performed 'on demand', i.e. the first time a message is requested, the appropriate file is read and all its contents cached in memory so that subsequent requests will be serviced more quickly.
Message Files
Individual message files are contained within a single directory which is specified as an argument to the constructor. The name of message files follows the syntax:-
msg-dir '/' [org-name '/'] [lang'/'] app-nane '.msg'
Messages requested internally by the OpenTop library will have an org-name of 'elcel' and an app-name equal to the OpenTop namespace of the requesting component.
| Constructor/Destructor Detail |
FileMessageFactory
FileMessageFactory(const String& msgDirectory,
const String lang)
-
Constructor.
- Parameters:
msgDirectory -
the name of a directory which will be searched for OpenTop message files.
lang -
the language that messages should be displayed in. This is used when constructing the filenames of message files within the directory specified by msgDirectory.
getMessageSet
protected virtual RefPtr< MessageSet > getMessageSet(const String& org,
const String& app)
-
Install
static void Install()
-
Static function to install an instance of FileMessageFactory as the system's MessageFactory.
This function tests if the environment variable ET_MSG_DIR is defined and, if so, uses its value as the name of a directory which will be searched for OpenTop message files.
If you need to install a FileMessageFactory using a different directory name, then you may construct a FileMessageFactory using the directory of your choice and then call System::SetMessageFactory() to install the instance as the system's MessageFactory.
Found a bug or missing feature? Please email us at support@elcel.com