=========================================================================
How to use the TGrid/TAlien class V1.0 - Andreas.Peters@cern.ch
=========================================================================

To connect to Alien you have to connect to a running API service or you
let the system start an API server on your local machine, if you have a
full AliEn client installation.

Creating <gGrid> instance:
1.  // connecting to an API service on the local machine
    // if there is already one running, it is reused!

    TGrid::Connect("alien://localhost");
    or
    TGrid::Connect("alien://");

2.  // connecting to an already running API server
    TGrid::Connect("alien://<host>:<port>/#?direct");

3.  // asking the factory service to startup an API on a service machine
    // (currently not working)
    TGrid::Connect("alien://<factoryhost>:<factoryport>");

If you have executed TGrid::Connect(), the gGrid global variable
should be set != 0.

Examples of gGrid usage:

1) List directories of the catalogue:

   int handle = gGrid->OpenDir("<aliendir>");
   TGridResult *gr = gGrid->CreateGridResult(handle);
   gr->Print();
   delete gr;

2) Find all files under a directory:

   int handle = gGrid->Find("<aliendir>","*","");
   TGridResult *gr = gGrid->CreateGridResult(handle);
   gr->Print();
   delete gr;

3) Inserting Files in the catalogue

   if (!gGrid) {
      TGrid::Connect("alien://aliens7.cern.ch:15000/?direct","");
   }

   TString dirname("/alice_mdc/user/a/alimdc/testdir");

   if ((gGrid->Mkdir(dirname)) < 0) {
      cout << "Error in Mkdir " << dirname << endl;
   }

   TString fname("/alice_mdc/user/a/alimdc/rootdir/file");

   if ((gGrid->AddFile(fname, "castor:///castor/cern.ch/test.root",
                       100, "Alice::CERN::Castor",
                       "003cce72-d0b2-1f30-aeff-c20c802abeef")) < 0) {
      cout << "Error in AddFile " << fname << endl;
   }

4) Tagging Files in the catalogue

   // adding a single attribute
   if ((gGrid->AddAttribute(fname, "mdc4", "filesize", "1000")) < 0) {
      cout << "Error adding attribute to " << fname << endl;
   }

   // adding multiple attributes
   if ((gGrid->AddAttribute(fname, "mdc4", "filesize", "1000", "offset",
                            "100")) < 0) {
      cout << "Error adding attribute to " << fname << endl;
   } // one can just continue the list of tags with more values ->
     // variable argument list
