// @(#)root/net:$Name: $:$Id: TGridJDL.cxx,v 1.2 2005/09/04 15:16:12 brun Exp $
// Author: Jan Fiete Grosse-Oetringhaus 28/9/2004
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
//////////////////////////////////////////////////////////////////////////
// //
// TGridJDL //
// //
// Abstract base class to generate JDL files for job submission to the //
// Grid. //
// //
// Related classes are TGLiteJDL. //
// //
//////////////////////////////////////////////////////////////////////////
#include "TGridJDL.h"
#include "TObjString.h"
#include "Riostream.h"
ClassImp(TGridJDL)
//______________________________________________________________________________
TGridJDL::~TGridJDL()
{
// Cleanup.
Clear();
}
//______________________________________________________________________________
void TGridJDL::Clear(const Option_t*)
{
// Clears the JDL information.
fMap.DeleteAll();
}
//______________________________________________________________________________
void TGridJDL::SetValue(const char *key, const char *value)
{
// Sets a value. If the entry already exists the old one is replaced.
TObject *object = fMap.FindObject(TString(key));
TPair *pair = dynamic_cast<TPair*>(object);
if (pair) {
TObject *oldObject = pair->Key();
if (oldObject) {
TObject *oldValue = pair->Value();
fMap.Remove(oldObject);
delete oldObject;
oldObject = 0;
if (oldValue) {
delete oldValue;
oldValue = 0;
}
}
}
fMap.Add(new TObjString(key), new TObjString(value));
}
//______________________________________________________________________________
const char *TGridJDL::GetValue(const char *key)
{
// Returns the value corresponding to the provided key. Return 0 in case
// key is not found.
if (!key)
return 0;
TObject *object = fMap.FindObject(TString(key));
if (!object)
return 0;
TPair *pair = dynamic_cast<TPair*>(object);
if (!pair)
return 0;
TObject *value = pair->Value();
if (!value)
return 0;
TObjString *string = dynamic_cast<TObjString*>(value);
if (!string)
return 0;
return string->GetString();
}
//______________________________________________________________________________
TString TGridJDL::AddQuotes(const char *value)
{
// Adds quotes to the provided string.
// E.g. Value --> "Value"
TString temp = TString("\"");
temp += value;
temp += "\"";
return temp;
}
//______________________________________________________________________________
void TGridJDL::AddToSet(const char *key, const char *value)
{
// Adds a value to a key value which hosts a set of values.
// E.g. InputSandbox: {"file1","file2"}
const char *oldValue = GetValue(key);
TString newString;
if (oldValue)
newString = oldValue;
if (newString.IsNull()) {
newString = "{";
} else {
newString.Remove(newString.Length()-1);
newString += ",";
}
newString += AddQuotes(value);
newString += "}";
SetValue(key, newString);
}
//______________________________________________________________________________
TString TGridJDL::Generate()
{
// Generates the JDL snippet.
TString output("");
TIter next(&fMap);
TObject *object = 0;
while ((object = next())) {
TObjString *key = dynamic_cast<TObjString*>(object);
if (key) {
TObject *value = fMap.GetValue(object);
TObjString *valueobj = dynamic_cast<TObjString*>(value);
if (valueobj) {
output += key->GetString();
output += " = ";
output += valueobj->GetString();
output += ";\n";
}
}
}
return output;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.