00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "TGLiteResult.h"
00036 #include "TObjString.h"
00037 #include "TMap.h"
00038 #include "Riostream.h"
00039 #include "TSystem.h"
00040 #include "TUrl.h"
00041 #include "TFileInfo.h"
00042
00043 #include <cstdlib>
00044
00045 ClassImp(TGLiteResult)
00046
00047
00048 void TGLiteResult::DumpResult()
00049 {
00050
00051
00052 cout << "BEGIN DUMP" << endl;
00053 cout << "END DUMP" << endl;
00054 }
00055
00056
00057 const char *TGLiteResult::GetFileName(UInt_t i) const
00058 {
00059
00060 if (At(i)) {
00061 TObjString * entry;
00062 if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("name"))) {
00063 return entry->GetName();
00064 }
00065 }
00066 return 0;
00067 }
00068
00069
00070 const char *TGLiteResult::GetFileNamePath(UInt_t i) const
00071 {
00072
00073 if (At(i)) {
00074 TObjString * entry;
00075 if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("name"))) {
00076 TObjString * path;
00077 if ((path = (TObjString*)((TMap*) At(i)) ->GetValue("path"))) {
00078 TString fFilePath(TString(path->GetName()) + TString(entry->GetName()));
00079 return fFilePath;
00080 }
00081 }
00082 }
00083 return 0;
00084 }
00085
00086
00087 const char *TGLiteResult::GetPath(UInt_t i) const
00088 {
00089
00090 if (At(i)) {
00091 TObjString * entry;
00092 if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("path"))) {
00093 return entry->GetName();
00094 }
00095 }
00096 return 0;
00097 }
00098
00099
00100 const char *TGLiteResult::GetKey(UInt_t i, const char* key) const
00101 {
00102
00103 if (At(i)) {
00104 TObjString * entry;
00105 if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue(key))) {
00106 return entry->GetName();
00107 }
00108 }
00109 return 0;
00110 }
00111
00112
00113 Bool_t TGLiteResult::SetKey(UInt_t i, const char* key, const char* value)
00114 {
00115
00116 if (At(i)) {
00117 TPair * entry;
00118 if ((entry = (TPair*)((TMap*) At(i)) ->FindObject(key))) {
00119 TObject * val = ((TMap*) At(i)) ->Remove((TObject*) entry->Key());
00120 if (val) {
00121 delete val;
00122 }
00123 }
00124 ((TMap*) At(i)) ->Add((TObject*)(new TObjString(key)),
00125 (TObject*)(new TObjString(value)));
00126 return kTRUE;
00127 }
00128 return kFALSE;
00129 }
00130
00131
00132 TList *TGLiteResult::GetFileInfoList() const
00133 {
00134
00135 TList * newfileinfolist = new TList();
00136
00137
00138
00139
00140 newfileinfolist->SetOwner(kTRUE);
00141
00142 for (Int_t i = 0; i < GetSize(); i++) {
00143
00144 Long64_t size = -1;
00145 if (GetKey(i, "size"))
00146 size = atol(GetKey(i, "size"));
00147
00148 const char* md5 = GetKey(i, "md5");
00149 const char* uuid = GetKey(i, "guid");
00150 const char* msd = GetKey(i, "msd");
00151
00152 if (md5 && !strlen(md5))
00153 md5 = 0;
00154 if (uuid && !strlen(uuid))
00155 uuid = 0;
00156 if (msd && !strlen(msd))
00157 msd = 0;
00158
00159 TString turl = GetKey(i, "turl");
00160
00161 if (msd) {
00162 TUrl urlturl(turl);
00163 TString options = urlturl.GetOptions();
00164 options += "&msd=";
00165 options += msd;
00166 urlturl.SetOptions(options);
00167 turl = urlturl.GetUrl();
00168 }
00169 Info("GetFileInfoList", "Adding Url %s with Msd %s\n", turl.Data(), msd);
00170 newfileinfolist->Add(new TFileInfo(turl, size, uuid, md5));
00171 }
00172 return newfileinfolist;
00173 }
00174
00175
00176 void TGLiteResult::Print(Option_t * , Option_t *option) const
00177 {
00178
00179
00180 if (TString(option) != TString("all")) {
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 } else {
00199 TIter next(this);
00200 TMap *map;
00201 for (Int_t count = 0; (map = dynamic_cast<TMap*>(next())); ++count) {
00202 TIter next2(map->GetTable());
00203 TPair *pair;
00204 cout << "# " << setiosflags(ios::left) << setw(6) << count << " ------------------------------------------------------------" << endl;
00205 while ((pair = dynamic_cast< TPair*>(next2()))) {
00206 TObjString * keyStr = dynamic_cast<TObjString*>(pair->Key());
00207 TObjString* valueStr = dynamic_cast<TObjString*>(pair->Value());
00208 if (keyStr && valueStr) {
00209 cout
00210 << setw(16) << keyStr->GetName()
00211 << valueStr->GetName()
00212 << endl;
00213 }
00214 }
00215 cout << endl;
00216 }
00217 }
00218 }
00219
00220
00221 void TGLiteResult::Print(Option_t *option) const
00222 {
00223
00224 Print("", option);
00225 }