Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

Context Class Reference
[Back-end Utility Components]

#include <pantheios/util/backends/context.hpp>

List of all members.


Detailed Description

Framework class for assisting in the writing of Back-ends.

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)
 
Note:
This method does not mutate any member data.

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.

Constructor & Destructor Documentation

Context ( pan_char_t const *  processIdentity,
int  id,
pan_uint32_t  flags,
int  severityMask 
) [protected]

Constructs an instance.

Parameters:
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


Member Function Documentation

int logEntry ( int  severity,
pan_char_t const *  entry,
size_t  cchEntry 
)

Note:
This method does not mutate any member data.

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).

Note:
Because the method does not, in and of itself, mutate data, backends using the class may only need to lock if the underlying transmission medium requires it, and this may only need to be inside the call to rawLogEntry(), on a back-end-specific basis.

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.

Note:
In builds where exceptions are not enabled, or with compilers that do not throw std::bad_alloc on allocation failure, this will return NULL to indicate that construction has failed


The documentation for this class was generated from the following file:

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo