Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGrid.cxx
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Fons Rademakers 3/1/2002
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGrid //
15 // //
16 // Abstract base class defining interface to common GRID services. //
17 // //
18 // To open a connection to a GRID use the static method Connect(). //
19 // The argument of Connect() is of the form: //
20 // <grid>[://<host>][:<port>], e.g. alien://alice.cern.ch //
21 // Depending on the <grid> specified an appropriate plugin library //
22 // will be loaded which will provide the real interface. //
23 // //
24 // Related classes are TGridResult. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include "TGrid.h"
29 #include "TROOT.h"
30 #include "TPluginManager.h"
31 #include "TError.h"
32 
33 TGrid *gGrid = 0;
34 
35 
36 ClassImp(TGrid);
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// The grid should be of the form: <grid>://<host>[:<port>],
40 /// e.g.: alien://alice.cern.ch
41 /// The uid is the username and pw the password that should be used for
42 /// the connection. Depending on the <grid> the shared library (plugin)
43 /// for the selected system will be loaded. When the connection could not
44 /// be opened 0 is returned. For AliEn the supported options are:
45 /// -domain=<domain name>
46 /// -debug=<debug level from 1 to 10>
47 /// Example: "-domain=cern.ch -debug=5"
48 
49 TGrid *TGrid::Connect(const char *grid, const char *uid, const char *pw,
50  const char *options)
51 {
52  TPluginHandler *h;
53  TGrid *g = 0;
54 
55  if (!grid) {
56  ::Error("TGrid::Connect", "no grid specified");
57  return 0;
58  }
59  if (!uid)
60  uid = "";
61  if (!pw)
62  pw = "";
63  if (!options)
64  options = "";
65 
66  if ((h = gROOT->GetPluginManager()->FindHandler("TGrid", grid))) {
67  if (h->LoadPlugin() == -1)
68  return 0;
69  g = (TGrid *) h->ExecPlugin(4, grid, uid, pw, options);
70  }
71 
72  return g;
73 }