|
#include <pantheios/util/backends/context.hpp>
To use pantheios::util::backends::Context, you derive from it, and override the rawLogEntry() method, as in the implementation of be.speech:
struct be_speech_context : public pantheios::util::backends::Context { public: // Member Types typedef pantheios::util::backends::Context parent_class_type; typedef be_speech_context class_type; typedef std::string string_type; typedef stlsoft::ref_ptr<ISpVoice> voice_type;
public: // Construction be_speech_context(pan_char_t const* processIdentity, int id, pantheios::uint32_t flags, voice_type voice); ~be_speech_context() throw();
private: // Overrides virtual int rawLogEntry(int severity, const pan_slice_t (&ar)[rawLogArrayDimension], size_t cchTotal);
. . . };
An instance of the derived class is created in the back-end initialisation function, and destroyed in the uninitialisation function, each of which are called a maximum of one time per program execution.
Finally, in the implementation of the back-end's log entry function, the logEntry() method is called, as in:
static int pantheios_be_speech_logEntry( void* // feToken , void* beToken , int severity , pan_char_t const* entry , size_t cchEntry) { PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != beToken, "back-end token may not be null");
be_speech_context* ctxt = static_cast<be_speech_context*>(beToken);
return ctxt->logEntry(severity, entry, cchEntry); }
Member Variables | |
pan_char_t *const | m_processIdentity |
int const | m_id |
pan_uint32_t const | m_flags |
int const | m_severityMask |
Public Types | |
Member Types | |
typedef Context | class_type |
Public Member Functions | |
Operations | |
int | logEntry (int severity, pan_char_t const *entry, size_t cchEntry) |
| |
Accessors | |
pan_char_t const * | getProcessIdentity () const |
The process identity. | |
int | getBackEndId () const |
Protected Types | |
Member Constants | |
enum | { rawLogArrayDimension = 10 } |
Protected Member Functions | |
Construction | |
Context (pan_char_t const *processIdentity, int id, pan_uint32_t flags, int severityMask) | |
Constructs an instance. | |
virtual | ~Context () throw () |
Static Protected Member Functions | |
Utilities | |
static size_t | concatenateSlices (pan_char_t *dest, size_t cchDest, size_t numSlices, pan_slice_t const *slices) |
Concatenates the slices into the given destination. |
Context | ( | pan_char_t const * | processIdentity, | |
int | id, | |||
pan_uint32_t | flags, | |||
int | severityMask | |||
) | [protected] |
Constructs an instance.
processIdentity | The process identity. May not be NULL or empty | |
id | The back-end identifier | |
flags | Flags that control the elements presented in the log statements | |
severityMask | Mask that prescribes the valid range of the severity for the derived class. Must be either 0x07 or 0x0f |
int logEntry | ( | int | severity, | |
pan_char_t const * | entry, | |||
size_t | cchEntry | |||
) |
It is not marked const
solely because it invokes rawLogEntry(), which may need to mutate member data of the derived class (though this will not be the dominant form).
static size_t concatenateSlices | ( | pan_char_t * | dest, | |
size_t | cchDest, | |||
size_t | numSlices, | |||
pan_slice_t const * | slices | |||
) | [static, protected] |
Concatenates the slices into the given destination.
pan_char_t const* getProcessIdentity | ( | ) | const |
The process identity.
|
|
pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 |