00001 // @(#)root/clarens:$Id: TClarens.cxx 20882 2007-11-19 11:31:26Z rdm $ 00002 // Author: Maarten Ballintijn 21/10/2004 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // TClarens // 00015 // // 00016 // // 00017 ////////////////////////////////////////////////////////////////////////// 00018 00019 #include "TClarens.h" 00020 00021 00022 #include "TClSession.h" 00023 #include "TEcho.h" 00024 #include "TGM.h" 00025 #include "THashList.h" 00026 #include "TLM.h" 00027 #include "TSAM.h" 00028 #include "TXmlRpc.h" 00029 00030 00031 namespace { 00032 00033 //------------------------------------------------------------------------------ 00034 00035 struct TClarensStartup { 00036 TClarensStartup() {TClarens::Init();} 00037 } Clarenstartup; 00038 00039 }; 00040 00041 00042 //------------------------------------------------------------------------------ 00043 00044 TClarens *gClarens = 0; 00045 00046 ClassImp(TClarens) 00047 00048 00049 //______________________________________________________________________________ 00050 TClarens::TClarens() 00051 : fTimeout(10000), fSessions(new THashList) 00052 { 00053 xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, "ROOT Clarens client", "1.0"); 00054 } 00055 00056 00057 //______________________________________________________________________________ 00058 TClarens::~TClarens() 00059 { 00060 delete fSessions; 00061 xmlrpc_client_cleanup(); 00062 } 00063 00064 00065 //______________________________________________________________________________ 00066 TClSession *TClarens::Connect(const Char_t * url) 00067 { 00068 TClSession *session = (TClSession*) fSessions->FindObject(url); 00069 00070 if (session == 0) { 00071 session = TClSession::Create(url); 00072 if (session != 0) fSessions->Add(session); 00073 } 00074 00075 return session; 00076 } 00077 00078 00079 //______________________________________________________________________________ 00080 TEcho *TClarens::CreateEcho(const Char_t * echoUrl) 00081 { 00082 TClSession *session = Connect(echoUrl); 00083 00084 if (session == 0) return 0; 00085 00086 return new TEcho(new TXmlRpc(session)); 00087 } 00088 00089 00090 //______________________________________________________________________________ 00091 TGM *TClarens::CreateGM(const Char_t * gmUrl) 00092 { 00093 TClSession *session = Connect(gmUrl); 00094 00095 if (session == 0) return 0; 00096 00097 return new TGM(new TXmlRpc(session)); 00098 } 00099 00100 00101 //______________________________________________________________________________ 00102 TLM *TClarens::CreateLM(const Char_t * lmUrl) 00103 { 00104 TClSession *session = Connect(lmUrl); 00105 00106 if (session == 0) return 0; 00107 00108 return new TLM(new TXmlRpc(session)); 00109 } 00110 00111 00112 //______________________________________________________________________________ 00113 TSAM *TClarens::CreateSAM(const Char_t * samUrl) 00114 { 00115 TClSession *session = Connect(samUrl); 00116 00117 if (session == 0) return 0; 00118 00119 return new TSAM(new TXmlRpc(session)); 00120 } 00121 00122 00123 //______________________________________________________________________________ 00124 void TClarens::Init() 00125 { 00126 if (gClarens == 0) { 00127 gClarens = new TClarens; 00128 } 00129 }