| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# GFALStageFile Class Reference

`#include <GaudiGridSvc/GFALStageFile.h>`

Collaboration diagram for GFALStageFile:

[legend]

List of all members.

## Detailed Description

Author:
  Andres Felipe Osorio Oliveros

  Greig Cowan

Date:
  2006-11-11

Definition at line 31 of file GFALStageFile.h.

## Public Types
enum | Status { FAILED = -1, STGING, STGED, EXIST, UNKNOWN }
## Public Member Functions
| GFALStageFile ()
| Standard constructor.
| GFALStageFile (std::string name, IMessageSvc *ms)
| GFALStageFile (const GFALStageFile &)
GFALStageFile & | operator= (const GFALStageFile &)
virtual | ~GFALStageFile ()
StatusCode | initialize ()
Status | getStatus () const
int | getRequestID () const
std::string | getSurl () const
std::string | getTurl () const
bool | isPFN () const
void | setStatus (int)
void | setSurl (const std::string &)
void | setTurl (const std::string &)
void | setRequestID (int)
const std::string | fileName () const
const std::string | rawFileName () const
bool | isValid () const
IMessageSvc * | msgSvc () const
## Static Public Member Functions
static const std::string | name ()
## Private Attributes
std::string | m_filename
std::string | m_rawfilename
Status | m_status
int | m_reqid
std::string | m_surl
std::string | m_turl
bool | is_pfn
bool | is_lfn
bool | is_guid
bool | is_surl
bool | m_isvalid
IMessageSvc * | m_MS

## Member Enumeration Documentation

enum GFALStageFile::Status

Enumerator:

  FAILED |
  STGING |
  STGED |
  EXIST |
  UNKNOWN |

Definition at line 34 of file GFALStageFile.h.

    00034 {FAILED=-1,STGING,STGED,EXIST,UNKNOWN};

## Constructor & Destructor Documentation

GFALStageFile::GFALStageFile | ( |  | ) |

Standard constructor.

Definition at line 26 of file GFALStageFile.cpp.

    00026                                {
    00027
    00028 }

GFALStageFile::GFALStageFile | ( | std::string | name,
|  | IMessageSvc * | ms |
| ) |  |  |

Definition at line 30 of file GFALStageFile.cpp.

    00031 {
    00032
    00033   Tokenizer tok(true);
    00034
    00035   m_MS=ms;
    00036
    00037   m_rawfilename = name ;
    00038
    00039   tok.analyse(m_rawfilename, " ", "", "", "=", "'", "'");
    00040   for ( Tokenizer::Items::iterator i = tok.items().begin();
    00041         i != tok.items().end();
    00042         i++ )   {
    00043     const std::string& tag = (*i).tag();
    00044     const std::string& val = (*i).value();
    00045     if (::toupper(tag[0])=='D') {
    00046       name = val ;
    00047     }
    00048   }
    00049
    00050   std::vector<std::string> prefixname;
    00051
    00052   prefixname.push_back("PFN:");
    00053   prefixname.push_back("LFN:");
    00054   prefixname.push_back("lfn:");
    00055   prefixname.push_back("guid:");
    00056   prefixname.push_back("surl:");
    00057   prefixname.push_back("srm:");
    00058   prefixname.push_back("gfal:");
    00059   prefixname.push_back("rfio:");
    00060   //prefixname.push_back("castor:");
    00061
    00062   m_isvalid = true;
    00063
    00064   is_pfn  = false;
    00065   is_guid = false;
    00066   is_lfn  = false;
    00067   is_surl = false;
    00068
    00069   for(std::vector<std::string>::iterator i = prefixname.begin() ;
    00070       i != prefixname.end();
    00071       ++i) {
    00072     size_t begpos = name.find(*i) ;
    00073     if ( begpos != name.npos ) {
    00074       size_t ntmp = i->length();
    00075       name.erase(begpos,ntmp);
    00076       if ((*i)        == prefixname[0] ) {
    00077         is_pfn = true;
    00078       } else if ((*i) == prefixname[1] || (*i) == prefixname[2]) {
    00079         is_lfn = true;
    00080       } else if ((*i) == prefixname[3] ) {
    00081         is_guid = true;
    00082       } else if ((*i) == prefixname[4] || (*i) == prefixname[5]) {
    00083         is_surl = true;
    00084       }
    00085       else { }
    00086     }
    00087   }
    00088
    00089
    00090   m_filename = name ;
    00091   m_status = UNKNOWN;
    00092   m_MS=ms;
    00093
    00094
    00095 }

GFALStageFile::GFALStageFile | ( | const GFALStageFile & | rhs | ) |

Definition at line 97 of file GFALStageFile.cpp.

    00098 {
    00099   m_filename    = rhs.m_filename;
    00100   m_rawfilename = rhs.m_rawfilename;
    00101   m_status      = rhs.m_status;
    00102   m_reqid       = rhs.m_reqid;
    00103   m_surl        = rhs.m_surl;
    00104   m_turl        = rhs.m_turl;
    00105   is_pfn        = rhs.is_pfn;
    00106   is_lfn        = rhs.is_lfn;
    00107   is_guid       = rhs.is_guid;
    00108   is_surl       = rhs.is_surl;
    00109   m_isvalid     = rhs.m_isvalid;
    00110   m_MS          = rhs.m_MS;
    00111
    00112 }

GFALStageFile::~GFALStageFile | ( |  | ) | `[virtual]`

Definition at line 141 of file GFALStageFile.cpp.

    00141 {}

## Member Function Documentation

GFALStageFile & GFALStageFile::operator= | ( | const GFALStageFile & | rhs | ) |

Definition at line 115 of file GFALStageFile.cpp.

    00116 {
    00117
    00118   if (this != &rhs) {
    00119     m_filename    = rhs.m_filename;
    00120     m_rawfilename = rhs.m_rawfilename;
    00121     m_status      = rhs.m_status;
    00122     m_reqid       = rhs.m_reqid;
    00123     m_surl        = rhs.m_surl;
    00124     m_turl        = rhs.m_turl;
    00125     is_pfn        = rhs.is_pfn;
    00126     is_lfn        = rhs.is_lfn;
    00127     is_guid       = rhs.is_guid;
    00128     is_surl       = rhs.is_surl;
    00129     m_isvalid     = rhs.m_isvalid;
    00130     m_MS          = rhs.m_MS;
    00131
    00132   }
    00133
    00134   return *this ;
    00135
    00136 }

StatusCode GFALStageFile::initialize | ( |  | ) |

Definition at line 144 of file GFALStageFile.cpp.

    00145 {
    00146
    00147   MsgStream log( msgSvc(), name() );
    00148
    00149   log << MSG::DEBUG << "initialise()" << endreq;
    00150
    00151   char errbuf[512];
    00152   int errbufsz = 512;
    00153   char * ptr_errbuf = errbuf;
    00154   char * ptr_guid;
    00155   char * ptr_surl;
    00156
    00157   if ( is_pfn ) {
    00158     log << MSG::DEBUG << "File is PFN" << endreq;
    00159     m_surl = std::string("srm://castorgridsc.cern.ch") + m_filename;
    00160     m_status = EXIST;
    00161   }
    00162
    00163   else if ( is_lfn ) {
    00164     m_filename = std::string("/grid") + m_filename;
    00165     log << MSG::DEBUG << "filename: " << m_filename << endreq;
    00166     ptr_guid = guidfromlfn( m_filename.c_str(), ptr_errbuf, errbufsz );
    00167     if (ptr_guid != NULL ) {
    00168       ptr_surl = surlfromguid( ptr_guid, ptr_errbuf, errbufsz );
    00169       if (ptr_surl == NULL ) {
    00170         log << MSG::DEBUG << "Failed to get surl from guid" << endreq;
    00171         log << MSG::ERROR << "surlfromguid> " << std::string(errbuf) << endreq;
    00172         m_isvalid = false;
    00173         return StatusCode::FAILURE;
    00174       }
    00175     }
    00176     else {
    00177       log << MSG::DEBUG << "Failed to get surl from lfn" << endreq;
    00178       m_isvalid = false;
    00179       return StatusCode::FAILURE;
    00180     }
    00181     m_surl = std::string(ptr_surl);
    00182     m_status = EXIST;
    00183   }
    00184
    00185   else if ( is_guid ) {
    00186     ptr_surl = surlfromguid( m_filename.c_str(), ptr_errbuf, errbufsz );
    00187     if (ptr_surl == NULL ) {
    00188       log << MSG::DEBUG << "Failed to get surl from guid" << endreq;
    00189       log << MSG::ERROR << "surlfromguid> " << std::string(errbuf) << endreq;
    00190       m_isvalid = false;
    00191       return StatusCode::FAILURE;
    00192     }
    00193     m_surl = std::string(ptr_surl);
    00194     m_status = EXIST;
    00195   }
    00196
    00197   else if ( is_surl ) {
    00198     m_surl = std::string("srm:") + m_filename;
    00199     m_status = EXIST;
    00200   }
    00201
    00202   else {
    00203     log << MSG::DEBUG << "initiliaze> failed to get SURL" << endreq;
    00204     log << MSG::DEBUG << "initialize> type of input unknown" << endreq;
    00205     m_isvalid = false;
    00206   }
    00207
    00208   log << MSG::DEBUG << "initiliaze> done." << endreq;
    00209
    00210   return StatusCode::SUCCESS;
    00211
    00212 }

GFALStageFile::Status GFALStageFile::getStatus | ( |  | ) | const

Definition at line 244 of file GFALStageFile.cpp.

    00245 {
    00246   return m_status ;
    00247 }

int GFALStageFile::getRequestID | ( |  | ) | const

Definition at line 261 of file GFALStageFile.cpp.

    00262 {
    00263   return m_reqid ;
    00264 }

std::string GFALStageFile::getSurl | ( |  | ) | const

Definition at line 267 of file GFALStageFile.cpp.

    00268 {
    00269   return m_surl ;
    00270 }

std::string GFALStageFile::getTurl | ( |  | ) | const

Definition at line 273 of file GFALStageFile.cpp.

    00274 {
    00275   return m_turl ;
    00276 }

bool GFALStageFile::isPFN | ( |  | ) | const

Definition at line 255 of file GFALStageFile.cpp.

    00256 {
    00257   return is_pfn;
    00258 }

void GFALStageFile::setStatus | ( | int | status | ) |

Definition at line 214 of file GFALStageFile.cpp.

    00215 {
    00216   if ( status == -1 ) {
    00217     m_status = FAILED;
    00218   }
    00219   else if ( status == 0 ) {
    00220     m_status = STGING;
    00221   }
    00222   else if ( status == 1 ) {
    00223     m_status = STGED;
    00224   }
    00225   else m_status = UNKNOWN;
    00226
    00227 }

void GFALStageFile::setSurl | ( | const std::string & | surl | ) |

Definition at line 229 of file GFALStageFile.cpp.

    00230 {
    00231   m_surl = surl;
    00232 }

void GFALStageFile::setTurl | ( | const std::string & | turl | ) |

Definition at line 234 of file GFALStageFile.cpp.

    00235 {
    00236   m_turl = turl;
    00237 }

void GFALStageFile::setRequestID | ( | int | reqid | ) |

Definition at line 239 of file GFALStageFile.cpp.

    00240 {
    00241   m_reqid = reqid;
    00242 }

static const std::string GFALStageFile::name | ( |  | ) | `[inline, static]`

Definition at line 57 of file GFALStageFile.h.

    00057 { return "StageFile" ; }

const std::string GFALStageFile::fileName | ( |  | ) | const`[inline]`

Definition at line 59 of file GFALStageFile.h.

    00059 { return m_filename ; }

const std::string GFALStageFile::rawFileName | ( |  | ) | const`[inline]`

Definition at line 61 of file GFALStageFile.h.

    00061 { return m_rawfilename ; }

bool GFALStageFile::isValid | ( |  | ) | const

Definition at line 250 of file GFALStageFile.cpp.

    00251 {
    00252   return m_isvalid ;
    00253 }

IMessageSvc * GFALStageFile::msgSvc | ( |  | ) | const

Definition at line 278 of file GFALStageFile.cpp.

    00279 {
    00280   return m_MS;
    00281 }

## Member Data Documentation

std::string GFALStageFile::m_filename`[private]`

Definition at line 71 of file GFALStageFile.h.

std::string GFALStageFile::m_rawfilename`[private]`

Definition at line 72 of file GFALStageFile.h.

Status GFALStageFile::m_status`[private]`

Definition at line 74 of file GFALStageFile.h.

int GFALStageFile::m_reqid`[private]`

Definition at line 75 of file GFALStageFile.h.

std::string GFALStageFile::m_surl`[private]`

Definition at line 77 of file GFALStageFile.h.

std::string GFALStageFile::m_turl`[private]`

Definition at line 78 of file GFALStageFile.h.

bool GFALStageFile::is_pfn`[private]`

Definition at line 80 of file GFALStageFile.h.

bool GFALStageFile::is_lfn`[private]`

Definition at line 81 of file GFALStageFile.h.

bool GFALStageFile::is_guid`[private]`

Definition at line 82 of file GFALStageFile.h.

bool GFALStageFile::is_surl`[private]`

Definition at line 83 of file GFALStageFile.h.

bool GFALStageFile::m_isvalid`[private]`

Definition at line 85 of file GFALStageFile.h.

IMessageSvc* GFALStageFile::m_MS`[mutable, private]`

Definition at line 87 of file GFALStageFile.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiGridSvc/src/GFALDataStreamTool/GFALStageFile.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiGridSvc/src/GFALDataStreamTool/GFALStageFile.cpp