// @(#)root/net:$Id$
// Author: Fons Rademakers   3/1/2002

/*************************************************************************
 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGrid
#define ROOT_TGrid

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGrid                                                                //
//                                                                      //
// Abstract base class defining interface to common GRID services.      //
//                                                                      //
// To open a connection to a GRID use the static method Connect().      //
// The argument of Connect() is of the form:                            //
//    <grid>://<host>[:<port>], e.g.                                    //
// alien://alice.cern.ch, globus://glsvr1.cern.ch, ...                  //
// Depending on the <grid> specified an appropriate plugin library      //
// will be loaded which will provide the real interface.                //
//                                                                      //
// Related classes are TGridResult.                                     //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif

#ifndef ROOT_TString
#include "TString.h"
#endif

#ifndef ROOT_TGridJob
#include "TGridJob.h"
#endif

class TGridResult;
class TGridJDL;
class TGridJob;
class TGridCollection;
class TGridJobStatusList;


class TGrid : public TObject {

protected:
   TString        fGridUrl; // the GRID url used to create the grid connection
   TString        fGrid;    // type of GRID (AliEn, Globus, ...)
   TString        fHost;    // GRID portal to which we are connected
   TString        fUser;    // user name
   TString        fPw;      // user passwd
   TString        fOptions; // options specified
   Int_t          fPort;    // port to which we are connected

public:
   TGrid() : fGridUrl(), fGrid(), fHost(), fUser(), fPw(), fOptions(), fPort(-1) { }
   virtual ~TGrid() { }

   const char    *GridUrl() const { return fGridUrl; }
   const char    *GetGrid() const { return fGrid; }
   const char    *GetHost() const { return fHost; }
   const char    *GetUser() const { return fUser; }
   const char    *GetPw() const { return fPw; }
   const char    *GetOptions() const { return fOptions; }
   Int_t          GetPort() const { return fPort; }
   virtual Bool_t IsConnected() const { return fPort == -1 ? kFALSE : kTRUE; }

   virtual void Shell() { MayNotUse("Shell"); }
   virtual void Stdout() { MayNotUse("Stdout"); }
   virtual void Stderr() { MayNotUse("Stderr"); }

   virtual TGridResult *Command(const char * /*command*/,
                                Bool_t /*interactive*/ = kFALSE,
                                UInt_t /*stream*/ = 2)
      { MayNotUse("Command"); return 0; }

   virtual TGridResult *Query(const char * /*path*/, const char * /*pattern*/,
                              const char * /*conditions*/ = "", const char * /*options*/ = "")
      { MayNotUse("Query"); return 0; }

   virtual TGridResult *LocateSites() { MayNotUse("LocalSites"); return 0; }

   //--- Catalogue Interface
   virtual TGridResult *Ls(const char* /*ldn*/ ="", Option_t* /*options*/ ="", Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Ls"); return 0; }
   virtual const char  *Pwd(Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Pwd"); return 0; }
   virtual const char  *GetHomeDirectory()
      { MayNotUse("GetHomeDirectory"); return 0; }
   virtual Bool_t Cd(const char* /*ldn*/ ="",Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Cd"); return kFALSE; }
   virtual Int_t  Mkdir(const char* /*ldn*/ ="", Option_t* /*options*/ ="", Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Mkdir"); return kFALSE; }
   virtual Bool_t Rmdir(const char* /*ldn*/ ="", Option_t* /*options*/ ="", Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Mkdir"); return kFALSE; }
   virtual Bool_t Register(const char* /*lfn*/ , const char* /*turl*/ , Long_t /*size*/ =-1, const char* /*se*/ =0, const char* /*guid*/ =0, Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Mkdir"); return kFALSE; }
   virtual Bool_t Rm(const char* /*lfn*/ , Option_t* /*option*/ ="", Bool_t /*verbose*/ =kFALSE)
      { MayNotUse("Mkdir"); return kFALSE; }

   //--- Job Submission Interface
   virtual TGridJob *Submit(const char * /*jdl*/)
      { MayNotUse("Submit"); return 0; }
   virtual TGridJDL *GetJDLGenerator()
      { MayNotUse("GetJDLGenerator"); return 0; }
   virtual TGridCollection *OpenCollection(const char *, UInt_t /*maxentries*/ = 1000000)
      { MayNotUse("OpenCollection"); return 0; }
   virtual TGridCollection *OpenCollectionQuery(TGridResult * /*queryresult*/,Bool_t /*nogrouping*/ = kFALSE)
      { MayNotUse("OpenCollection"); return 0; }
   virtual TGridJobStatusList* Ps(const char* /*options*/, Bool_t /*verbose*/ = kTRUE)
      { MayNotUse("Ps"); return 0; }
   virtual Bool_t KillById(TString /*jobid*/)
      { MayNotUse("KillById"); return kFALSE; }
   virtual Bool_t ResubmitById(TString /*jobid*/)
      { MayNotUse("ResubmitById"); return 0; }
   virtual Bool_t Kill(TGridJob *gridjob)
      { return ((gridjob)?KillById(gridjob->GetJobID()):kFALSE); }
   virtual Bool_t Resubmit(TGridJob* gridjob)
      { return ((gridjob)?ResubmitById(gridjob->GetJobID()):kFALSE); }

   //--- Load desired plugin and setup conection to GRID
   static TGrid *Connect(const char *grid, const char *uid = 0,
                         const char *pw = 0, const char *options = 0);

   ClassDef(TGrid,0)  // ABC defining interface to GRID services
};

R__EXTERN TGrid *gGrid;

#endif
 TGrid.h:1
 TGrid.h:2
 TGrid.h:3
 TGrid.h:4
 TGrid.h:5
 TGrid.h:6
 TGrid.h:7
 TGrid.h:8
 TGrid.h:9
 TGrid.h:10
 TGrid.h:11
 TGrid.h:12
 TGrid.h:13
 TGrid.h:14
 TGrid.h:15
 TGrid.h:16
 TGrid.h:17
 TGrid.h:18
 TGrid.h:19
 TGrid.h:20
 TGrid.h:21
 TGrid.h:22
 TGrid.h:23
 TGrid.h:24
 TGrid.h:25
 TGrid.h:26
 TGrid.h:27
 TGrid.h:28
 TGrid.h:29
 TGrid.h:30
 TGrid.h:31
 TGrid.h:32
 TGrid.h:33
 TGrid.h:34
 TGrid.h:35
 TGrid.h:36
 TGrid.h:37
 TGrid.h:38
 TGrid.h:39
 TGrid.h:40
 TGrid.h:41
 TGrid.h:42
 TGrid.h:43
 TGrid.h:44
 TGrid.h:45
 TGrid.h:46
 TGrid.h:47
 TGrid.h:48
 TGrid.h:49
 TGrid.h:50
 TGrid.h:51
 TGrid.h:52
 TGrid.h:53
 TGrid.h:54
 TGrid.h:55
 TGrid.h:56
 TGrid.h:57
 TGrid.h:58
 TGrid.h:59
 TGrid.h:60
 TGrid.h:61
 TGrid.h:62
 TGrid.h:63
 TGrid.h:64
 TGrid.h:65
 TGrid.h:66
 TGrid.h:67
 TGrid.h:68
 TGrid.h:69
 TGrid.h:70
 TGrid.h:71
 TGrid.h:72
 TGrid.h:73
 TGrid.h:74
 TGrid.h:75
 TGrid.h:76
 TGrid.h:77
 TGrid.h:78
 TGrid.h:79
 TGrid.h:80
 TGrid.h:81
 TGrid.h:82
 TGrid.h:83
 TGrid.h:84
 TGrid.h:85
 TGrid.h:86
 TGrid.h:87
 TGrid.h:88
 TGrid.h:89
 TGrid.h:90
 TGrid.h:91
 TGrid.h:92
 TGrid.h:93
 TGrid.h:94
 TGrid.h:95
 TGrid.h:96
 TGrid.h:97
 TGrid.h:98
 TGrid.h:99
 TGrid.h:100
 TGrid.h:101
 TGrid.h:102
 TGrid.h:103
 TGrid.h:104
 TGrid.h:105
 TGrid.h:106
 TGrid.h:107
 TGrid.h:108
 TGrid.h:109
 TGrid.h:110
 TGrid.h:111
 TGrid.h:112
 TGrid.h:113
 TGrid.h:114
 TGrid.h:115
 TGrid.h:116
 TGrid.h:117
 TGrid.h:118
 TGrid.h:119
 TGrid.h:120
 TGrid.h:121
 TGrid.h:122
 TGrid.h:123
 TGrid.h:124
 TGrid.h:125
 TGrid.h:126
 TGrid.h:127
 TGrid.h:128
 TGrid.h:129
 TGrid.h:130
 TGrid.h:131
 TGrid.h:132
 TGrid.h:133
 TGrid.h:134
 TGrid.h:135
 TGrid.h:136
 TGrid.h:137