Main Page | Namespace List | Class List | Namespace Members | Class Members

aiml::cInterpreter Class Reference

libaiml interpreter. More...

List of all members.

Public Member Functions

 cInterpreter (void)
 Initializes everything.
virtual ~cInterpreter (void)
 Deinitialize the core.
virtual bool initialize (const std::string &filename)=0
 Initialize the AIML core using configuration file.
virtual bool initialize (const std::string &filename, const cCoreOptions &opts)=0
 Initialize the AIML core using data passed from client program.
virtual void deinitialize (void)=0
 Deinitialize the core.
virtual void registerCallbacks (cInterpreterCallbacks *callbacks)=0
 Register callbacks for libaiml to use.
virtual bool respond (const std::string &input, const std::string &username, std::string &output, std::list< cMatchLog > *log=NULL)=0
 responder function.
virtual void unregisterUser (const std::string &username)=0
 Removes a user from the list in memory.
virtual bool learnFile (const std::string &filename)=0
 loads an .aiml file.
virtual bool saveGraphmaster (const std::string &file)=0
 Saves currently loaded graphmaster into a .caiml file.
virtual bool loadGraphmaster (const std::string &file)=0
 Loads a previously saved .caiml file into the core.
AIMLError getError (void)
 Get the last error set.
virtual std::string getErrorStr (AIMLError error_num)=0
 get the last error code generated in humanly readable form.
virtual std::string getRuntimeErrorStr (void)=0
 returns the last runtime error message set by the corresponding subsystem.

Static Public Member Functions

static cInterpreternewInterpreter (void)
 Create a new interpreter instance.
static void freeInterpreter (cInterpreter *i)
 Destroy a cInterpreter object.

Protected Attributes

AIMLError last_error
cInterpreterCallbackscallbacks


Detailed Description

libaiml interpreter.

This is the class to be used as the interface. It encapsulates the libaiml interpreter.


Constructor & Destructor Documentation

cInterpreter::~cInterpreter void   )  [virtual]
 

Deinitialize the core.

Calls deinitialize().


Member Function Documentation

virtual bool aiml::cInterpreter::initialize const std::string &  filename  )  [pure virtual]
 

Initialize the AIML core using configuration file.

Parameters:
filename is a path to the configuration file that libaiml uses.
Returns:
true iif initialization was successful

virtual bool aiml::cInterpreter::initialize const std::string &  filename,
const cCoreOptions opts
[pure virtual]
 

Initialize the AIML core using data passed from client program.

Parameters:
filename is the path to the libaiml configuration file (the <options> tag is ignored)
opts is the structure containing the values wanted for each option available.
Returns:
true iif initialization was successful

virtual void aiml::cInterpreter::deinitialize void   )  [pure virtual]
 

Deinitialize the core.

Saves all user variables into the user's files and shuts everything down. You don't have to call this explicitly, the destructor does it.

virtual bool aiml::cInterpreter::respond const std::string &  input,
const std::string &  username,
std::string &  output,
std::list< cMatchLog > *  log = NULL
[pure virtual]
 

responder function.

The output is touched iif the function returns true. The username will be created if this function is called for the first time with such parameter. The matching & response will be done inside the user's context. If the log parameter is used, it is used to store each of the matches made by the interpreter to reach the template. It is a list because it includes the top-level match and any possible internal <srai> matches made later.

Parameters:
input is the input that should be passed to the aiml interpreter.
username is the username or id that should be asociated with the conversation.
output is a reference to a string where the interpreter saves the response.
log is an optional pointer to a list to be used to store cMatchLog structures (user should provide the storage).
Returns:
true iif no errors were found.

virtual void aiml::cInterpreter::unregisterUser const std::string &  username  )  [pure virtual]
 

Removes a user from the list in memory.

Parameters:
username is the user's name as passed to respond().

virtual bool aiml::cInterpreter::learnFile const std::string &  filename  )  [pure virtual]
 

loads an .aiml file.

Parameters:
filename is the path (relative to client program) of the aiml file to load.
Returns:
if it was successful.

virtual bool aiml::cInterpreter::saveGraphmaster const std::string &  file  )  [pure virtual]
 

Saves currently loaded graphmaster into a .caiml file.

Parameters:
file is the name of the file.
Returns:
if saving was succesful.

virtual bool aiml::cInterpreter::loadGraphmaster const std::string &  file  )  [pure virtual]
 

Loads a previously saved .caiml file into the core.

This functions replaces the content of the graphmaster completely, so if you want to mix aiml files and ONE .caiml file (more wouldn't make sense), you should load all .aiml files first.

Parameters:
file is the name of the file.
Returns:
if loading was succesful.

virtual std::string aiml::cInterpreter::getErrorStr AIMLError  error_num  )  [pure virtual]
 

get the last error code generated in humanly readable form.

Parameters:
error_num is the error to interpret (you can take getError() output for this).

virtual std::string aiml::cInterpreter::getRuntimeErrorStr void   )  [pure virtual]
 

returns the last runtime error message set by the corresponding subsystem.

Returns:
the runtime error or an empty string if none was generated.

cInterpreter * cInterpreter::newInterpreter void   )  [static]
 

Create a new interpreter instance.

This is necessary because cInterpreter is an abstract interface, you couldn't build the interpreter yourself without seeing the implementation. The data returned is dynamically allocated with 'new', so you can call destroy on it afterwards.

Returns:
a pointer to the newly allocated interpreter object.

void cInterpreter::freeInterpreter cInterpreter i  )  [static]
 

Destroy a cInterpreter object.

You don't need to use this as you can just do 'delete i;'. This function is just defined for simmetry.


Generated on Fri Feb 3 00:27:21 2006 for libaiml by  doxygen 1.4.4