// @(#)root/proof:$Name:  $:$Id: TCondor.h,v 1.2 2003/09/23 08:54:50 rdm Exp $
// Author: Maarten Ballintijn   06/12/03

/*************************************************************************
 * Copyright (C) 1995-2003, 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_TCondor
#define ROOT_TCondor

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TCondor                                                              //
//                                                                      //
// Interface to the Condor system. TCondor provides a (partial) API for //
// querying and controlling the Condor system, including experimental   //
// extensions like COD (computing on demand)                            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

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


class TList;
class TObjString;


//------------------------------------------------------------------------

class TCondorSlave : public TObject {
public:
   TString  fHostname;
   Int_t    fPort;
   Int_t    fPerfIdx;
   TString  fImage;
   TString  fClaimID;

   void        Print(Option_t *option="") const;

   ClassDef(TCondorSlave,0)  // Describes a claimed slave
};


//------------------------------------------------------------------------

class TCondor : public TObject {
private:

   enum EState { kFree, kSuspended, kActive };

   TString  fPool;      // the condor pool to be accessed
   EState   fState;     // our claim state
   TList   *fClaims;    // list of claims we manage

protected:
   TCondorSlave  *ClaimVM(const char *vm, const char *cmd, Int_t &port);
   Bool_t         SetState(EState state);

public:
   TCondor(const char *pool = "");
   virtual ~TCondor();

   void        Print(Option_t *option="") const;

   TList      *GetVirtualMachines() const;

   TList      *Claim(Int_t n, const char *cmd);
   Bool_t      Suspend();
   Bool_t      Resume();
   Bool_t      Release();

   Bool_t      GetVmInfo(const char *vm, TString &image, Int_t &perfidx) const;
   TString     GetImage(const char *host) const;


   ClassDef(TCondor,0)  // Interface to the Condor System
};

#endif
