BT_RLP_Environment Class Reference

Runtime environment for the Rosette Linguistics Platform. More...

#include <bt_rlp.h>

List of all members.

Public Member Functions

virtual void DestroyContext (BT_RLP_Context *context)
 Destroys a context created with GetContextFromFile or GetContextFromBuffer.
virtual BT_Result GetContextFromBuffer (const unsigned char *buffer, BT_UInt32 len, BT_RLP_Context **context)
 Create a context within the current environment, initialized from a buffer.
virtual BT_Result GetContextFromFile (const char *context_path, BT_RLP_Context **context)
 Creates a context using the current environment, initialized from a file.
virtual void GetProcessorReport (char *buffer, BT_UInt32 buffer_size) const
 Gets a report on the processors defined in an environment.
virtual bool HasLicenseForLanguage (BT_LanguageID lid, BT_UInt32 functionality) const
 Determines if a license exists for the language and functionality.
virtual bool HasLicenseForNamedFeature (const char *feature, BT_UInt32 functionality) const
 Determines if a license exists for the feature and functionality.
virtual bool HasLicenses () const
 Determines if there are language and feature licenses in the environment.
virtual BT_Result InitializeFromBuffer (const unsigned char *buffer, BT_UInt32 len)
 Initializes an environment from a buffer containing configuration information.
virtual BT_Result InitializeFromFile (const char *pathname)
 Initialize an environment from a configuration file.
virtual ~BT_RLP_Environment ()
 Virtual Destructor.

Static Public Member Functions

static BT_RLP_EnvironmentCreate ()
 Creates a new RLP environment.
static char const * RootDirectory ()
 Query the BT_ROOT/rlp directory.
static void SetBTRootDirectory (char const *root_directory_pathname)
 Sets the BT_ROOT directory, globally.
static void SetLogCallbackFunction (void *info_p, BT_Log_callback_function fcn_p)
 Captures log output to a callback function.
static void SetLogLevel (char const *log_level_string)
 Globally set the logging control for RLP.
static void SetRootDirectory (char const *root_directory_pathname)
 Sets the BT_ROOT/rlp directory, globally.

Protected Member Functions

 BT_RLP_Environment (const BT_RLP_Environment &)
BT_RLP_Environmentoperator= (const BT_RLP_Environment &)


Detailed Description

This class encapsulates the RLP runtime environment and is responsible for maintaining input, output, and language processors.

See also:
BT_RLP_Context

Constructor & Destructor Documentation

virtual BT_RLP_Environment::~BT_RLP_Environment (  )  [virtual]

This is the virtual destructor.


Member Function Documentation

static BT_RLP_Environment* BT_RLP_Environment::Create (  )  [static]

This member function creates a new, uninitialized RLP environment.

The environment must be destroyed with the delete operator when you are finished with it.

Returns:
Newly created environment, or 0 if it cannot be allocated.

virtual void BT_RLP_Environment::DestroyContext ( BT_RLP_Context context  )  [virtual]

Destroys a context created with the GetContextFromFile or GetContextFromBuffer member functions. The context should not be used after it has been destroyed as the pointer will no longer be valid.

Note:
You should always use this function to release a context: do not use the delete operator.
Parameters:
context The context to destroy.

virtual BT_Result BT_RLP_Environment::GetContextFromBuffer ( const unsigned char *  buffer,
BT_UInt32  len,
BT_RLP_Context **  context 
) [virtual]

Return a new context within the current environment, initializing from a context description contained in buffer.

The character data in the buffer should be encoded in UTF-8.

Parameters:
buffer The buffer containing the XML data. The buffer can be discarded after this function is called.
len The length of the buffer.
context Address of the pointer for the created context.
Return values:
BT_OK The context was allocated and initialized correctly.

virtual BT_Result BT_RLP_Environment::GetContextFromFile ( const char *  context_path,
BT_RLP_Context **  context 
) [virtual]

This member function creates a context with the current environment configuration, based on the named context definition.

The character data in the file should be encoded in UTF-8.

Parameters:
context_path Pathname to the context configuration file.
context Address of the pointer for the created context.
Return values:
BT_OK The context was allocated and initialized correctly.

virtual void BT_RLP_Environment::GetProcessorReport ( char *  buffer,
BT_UInt32  buffer_size 
) const [virtual]

This member function fills in a string with a report on the processors defined in the environment. The string is delimited with vertical bars:

      proc0|desc0|proc1|desc1|...|procN|descN||

The string will be null-terminated on return. If the string was truncated, the trailing | will be missing.

Parameters:
buffer destination for the report.
buffer_size the maximum length of the report buffer.

virtual bool BT_RLP_Environment::HasLicenseForLanguage ( BT_LanguageID  lid,
BT_UInt32  functionality 
) const [virtual]

This member function determines if a license exists for the language and functionality.

Parameters:
lid Language ID.
functionality Functionality.
See also:
bt_language_names.h and bt_rlp_license_types.h
Return values:
true There is a license for the language and functionality.

virtual bool BT_RLP_Environment::HasLicenseForNamedFeature ( const char *  feature,
BT_UInt32  functionality 
) const [virtual]

This member function determines if a license exists for the feature and functionality.

Parameters:
feature Feature.
functionality Functionality.
See also:
bt_rlp_license_types.h
Return values:
true There is a license for the feature and functionality.

virtual bool BT_RLP_Environment::HasLicenses (  )  const [virtual]

This member function determines if there are language and feature licenses in the environment.

Return values:
true There are some language and feature licenses.

virtual BT_Result BT_RLP_Environment::InitializeFromBuffer ( const unsigned char *  buffer,
BT_UInt32  len 
) [virtual]

This member function initializes the environment from an XML configuration stored in the buffer.

Parameters:
buffer The buffer containing the XML data. The buffer can be discarded after this function is called.
len The length of the buffer.
Return values:
BT_OK The environment was initialized.

virtual BT_Result BT_RLP_Environment::InitializeFromFile ( const char *  pathname  )  [virtual]

This member function initializes the environment from the XML configuration file named by the argument.

Parameters:
pathname The pathname to the configuration file.
Return values:
BT_OK The environment was initialized.

static char const* BT_RLP_Environment::RootDirectory (  )  [static]

This static function returns the current location of the rlp subdirectory of the installation directory. It returns 0 in the event that no root directory is established. Generally, RLP does not function without a setting for the Basis root directory.

Returns:
the BT_ROOT/rlp directory, or 0 if none.

static void BT_RLP_Environment::SetBTRootDirectory ( char const *  root_directory_pathname  )  [static]

This static function establishes the root directory of a Basis Technology installation. This directory is known as BT_ROOT or the Basis root directory. RLP-specific files are found under BT_ROOT/rlp.

Parameters:
root_directory_pathname String specifying the root of the installation.

static void BT_RLP_Environment::SetLogCallbackFunction ( void *  info_p,
BT_Log_callback_function  fcn_p 
) [static]

This static function specifies a callback function to receive logging data, which is encoded in UTF-8. This should be called before any other RLP function. All log channels will be muted by this call. A subsequent call to SetLogLevel should be used to control the log level.

Note:
The log message is not necessarily a complete line or message.
      static x_log_callback(void* info_p, int channel, char const* message)
      {
          std::cerr << channel << "\t" << message << std::endl;
      }

      BT_RLP_Environment::SetLogCallbackFunction(0, x_log_callback);
      BT_RLP_Environment::SetLogLevel("error");

Parameters:
info_p Void pointer stored and passed to the callback function each time it is called. The interpretation of this value is solely at the discretion of the client.
fcn_p Function pointer to the callback function, which returns void and takes a void * (the value of info_p), int (channel number), and a char const * (the message).

static void BT_RLP_Environment::SetLogLevel ( char const *  log_level_string  )  [static]

This static function controls the level of diagnostic logging for RLP. Call it before a BT_RLP_Environment is initialized. There are three channels that can be enabled:

error
Fatal error messages.
warning
Non-fatal warning messages.
info
Informational messages.

By default, without calling SetLogLevel, "error" level messages will be logged. To turn off all logging, call SetLogLevel("none").

These can be combined to log multiple levels by separating each one with a comma, e.g., "error,warning". The string "all" is synonymous with "error,warning,info".

The environment variable BT_RLP_LOG_LEVEL can be set similarly to get the same behavior without explicitly calling SetLogLevel.

Parameters:
log_level_string String specifying which of the standard channels should be logged.

static void BT_RLP_Environment::SetRootDirectory ( char const *  root_directory_pathname  )  [static]

This static function establishes the location of Basis Technology installation as the parent directory of its parameter.

Parameters:
root_directory_pathname String specifying the location of the rlp directory under the Basis root directory.
Deprecated:
This API has been deprecated in rlp 5.4. Call SetBTRootDirectory instead. The use of the BT_ROOT environment variable to configure a root directory is no longer supported.


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

Copyright © 2004-2008 Basis Technology Corporation. All Rights Reserved.