BLADE Tutorial

HOME

Overview

The API for BLADE consists of the following two classes:

Example

The following program shows how a broker can be started so that it listens to port 9999 and sends notifications:

#include "Blade.h"

int main()
{
  //set the parameters to blade
  BladeParams params;
  params.SetPort(9999);
  params.SetNotify(true);

  //create the blade object
  Blade *blade = new Blade(params);

  //start the broker
  blade->Start();

  //even though the call to Start returns, the components
  //of the broker are executing in separate threads. the broker
  //can only keep going if we do not terminate here.
  while(true) {}

  return 0;
}
 

Notice that the program includes the header file Blade.h where the two classes are declared. If we save this program to a file blade.cpp then we can compile it on Linux as follows:

$ g++ -DBLADE_OS_LINUX blade.cpp -lblade -lspear -pthread

Obviously the blade and spear libraries must be in the same directory as blade.cpp or appropriate command line options must be passed to g++ so that the linker can find these libraries. On Windows we can do the compilation as follows :

$ cl -DBLADE_OS_WIN32 blade.cpp libblade.lib libspear.lib -link -NODEFAULTLIB:LIBC.lib

Once again we have assumed that the libraries are in the current directory. Otherwise appropriate linker options must be supplied.

BLADE Query Language

The query language supported by BLADE is like a boolean fragment of XQL. Its grammar is given by the following BNF:

query
       := atomic_query
       |  '(' query ')'
       |  '$not$' atomic_query
       |  atomic_query '$and$' atomic_query
       |  atomic_query '$or$' atomic_query

atomic_query
       := var int_rel_op int_const
       |  var dbl_rel_op dbl_const
       |  var str_rel_op str_const

var := a collection of characters not beginning with a single or double quote, '$', digit, '=', '<', '>', '!', '+', '-', '.', '(', ')' or whitespace and not containing a single or double quote, '$', '=', '<', '>', '!', '+', '-', '.', '(', ')' or whitespace.

int_rel_op := '=' | '!=' | '<' | '<=' | '>' | '>=' | '$eq$' | '$ne$' | '$lt$' | '$le$' | '$gt$' | '$ge$'

dbl_rel_op := '=' | '!=' | '<' | '<=' | '>' | '>=' | '$eq$' | '$ne$' | '$lt$' | '$le$' | '$gt$' | '$ge$'

str_rel_op := '=' | '!=' | '$eq$' | '$ne$' | '$supstr$' | '$substr$' | '$prefix$' | '$suffix$' | '$starts$' | '$ends$'

int_const := a standard integer constant.

dbl_const := a standard double constant. exponential notation, e.g. 5e-10, 0.7E+2 etc. is allowed.

str_const := a sequence of characters delimited by single or double quotes e.g. 'foo', "bar". single and double quotes appearing in the constant must be escaped with a backslash.
 

Most of the relational operators have the usual meaning. The string operators $supstr$, $substr$, $prefix$, $suffix$, $starts$ and $ends$ have the following connotations:

API of BladeParams class

We now document the public methods of the BladeParams class. First we describe the modifier methods.

Modifier methods

Accessor Methods

For each of the modifier methods described above there is a corresponding accessor method that returns the current value of the option. These are mentioned below: If you wish to program in Java take a peek at the JBLADE tutorial . If you wish to write a client the SHAFT tutorial might be helpful.
  
HOME