BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
//
//

//
// $Id: BrDbFile.cxx,v 1.1.1.1 2001/06/21 14:55:17 hagel Exp $
// $Author: hagel $
// $Date: 2001/06/21 14:55:17 $
// $Copyright: 2000 Brahms Collaboration 
//

#include <BrDbFile.h>
#ifndef BRAT_BrException
#include "BrException.h"
#endif
#ifndef WIN32 
#include <cstdlib>
#include <iostream>
#else 
#include <stdlib.h>
#include <iostream.h>
#endif

ClassImp(BrDbFile);
 
//____________________________________________________________________
const Char_t* BrDbFile::kTableName = "Files";

//____________________________________________________________________
 BrDbFile::BrDbFile(void) 
{
  // Empty default constructor.
}

//____________________________________________________________________
 BrDbFile::BrDbFile(const Char_t* spoolFile,
		   Int_t   runNo,
		   Int_t   seqNo,
		   Int_t   fileStartTime,
		   Int_t   fileEndTime,
		   Int_t   sizeBytes,
		   Int_t   firstEventNo,
		   Int_t   lastEventNo,
		   Int_t   eventCount,
		   Int_t   hpssStartTime,
		   Int_t   hpssEndTime,
		   const Char_t* hpssFile,
		   const Char_t* triggerSummary)
{
  // Constructor.
  SetSpoolFile(spoolFile);
  fRunNo         = runNo;      
  fSeqNo         = seqNo;      
  fFileStartTime = fileStartTime;
  fFileEndTime   = fileEndTime;
  fSizeBytes     = sizeBytes;  
  fFirstEventNo  = firstEventNo;
  fLastEventNo   = lastEventNo;
  fEventCount    = eventCount; 
  fHPSSStartTime = hpssStartTime;
  fHPSSEndTime   = hpssEndTime;
  fTriggerSummary = 0;
  SetHPSSFile(hpssFile);
  SetTriggerSummary(triggerSummary);

  SetDBID(runNo * 1000 + seqNo);
}

//____________________________________________________________________
 BrDbQuery* BrDbFile::Create(void)
{
  // Returns a SQL query string suitable for creation of this table in
  // a database. 

  cerr << "BrDbFile::Create not implemented for this table"
       << endl;
  return new BrDbQuery();
}

//____________________________________________________________________
 BrDbFile* BrDbFile::SingleInstance(TSQLRow* row)
{
  // Returns an instance of a BrDbFile. User needs to store this
  // object imidiatly. 

  if (!row) return 0;

  Int_t firstEventNo= (row->GetField(6)  ? strtol(row->GetField(6),NULL,0):0);
  Int_t lastEventNo = (row->GetField(7)  ? strtol(row->GetField(7),NULL,0):0);
  Int_t hpssstart   = (row->GetField(9)  ? strtol(row->GetField(9),NULL,0):0);
  Int_t hpssend     = (row->GetField(10) ? strtol(row->GetField(10),NULL,0):0);

  BrDbFile* file = 
    new BrDbFile(row->GetField(0),                 // SpoolFile
		 strtol(row->GetField(1),NULL,0),  // RunNo
		 strtol(row->GetField(2),NULL,0),  // SeqNo
		 strtol(row->GetField(3),NULL,0),  // FileStartTime
		 strtol(row->GetField(4),NULL,0),  // FileEndTime 
		 strtol(row->GetField(5),NULL,0),  // SizeBytes
		 firstEventNo,                     // FirstEventNo
		 lastEventNo,                      // LastEventNo
		 strtol(row->GetField(8),NULL,0),  // EventCount
		 hpssstart, //strtol(row->GetField(9),NULL,0), // HPPSStartTime
		 hpssend,   //strtol(row->GetField(10),NULL,0),// HPPSEndTime
		 row->GetField(11),                // HPSSFile
		 row->GetField(12)                 // TriggerSummary
		 );

  return file;
}

//____________________________________________________________________
TObjArray*    
 BrDbFile::MultipleInstance(TSQLResult* res)
{
  // Returns an (1D) array of BrDbFile's matching Query that made
  // the TSQLResult. User need to store this immediately. 
  Int_t count = (res) ? res->GetRowCount() : 0;
  TObjArray* table = new TObjArray(count);

  for (Int_t i = 0; i < count; i++)
    table->Add(BrDbFile::SingleInstance(res->Next()));
  
  return table;
}

//____________________________________________________________________
BrDbQuery* 
 BrDbFile::Insert(void) 
{
  cerr << "BrDbFile::Insert not implemented for this table"
       << endl;
  return new BrDbQuery();
}

//____________________________________________________________________
 void BrDbFile::SetSpoolFile(const Char_t* x) {
  // Set FileType
  if (strlen(x) > 256) {
    strncpy(fSpoolFile, x, 255);
    fSpoolFile[255] = '0';
  } else 
    strcpy(fSpoolFile, x);
}

//____________________________________________________________________
 void BrDbFile::SetHPSSFile(const Char_t* x) {
  // Set FileType
  if(x) {
    if (strlen(x) > 256) {
      strncpy(fHPSSFile, x, 255);
      fHPSSFile[255] = '0';
    } else 
      strcpy(fHPSSFile, x);
  }
}

//____________________________________________________________________
 void BrDbFile::SetTriggerSummary(const Char_t* x) {
  // Set TriggerSummary
  fSummarySize = strlen(x) + 1;
  if (fTriggerSummary) 
    delete [] fTriggerSummary;
  fTriggerSummary = new Char_t[fSummarySize];
  strcpy(fTriggerSummary, x);
  fTriggerSummary[fSummarySize-1] = '0';
}

//____________________________________________________________________



//
// $Log: BrDbFile.cxx,v $
// Revision 1.1.1.1  2001/06/21 14:55:17  hagel
// Initial revision of brat2
//
// Revision 1.5  2001/06/05 18:40:37  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.4  2001/05/07 14:43:13  ouerdane
// Fixed initialization of pointer member fTriggerSummary.
//
// Revision 1.3  2001/04/20 16:13:46  hagel
// Rework MySQL mode of BrMagnetVolume
//
// Revision 1.2  2001/03/22 20:44:32  cholm
// Added protection for NULL TSqlRow in SingleInstance methods, and cleaned
// up a bit of the stuff.
//
// Revision 1.1  2001/01/19 16:30:51  cholm
// Revisited the Run database classes. Deleted old implemtation via BrRun,
// and put in BrDbRun, BrDbFile, BrDbMagnet, BrDbConditions*, and
// BrDbShiftReport. A description will be posted to brahms-dev-l soon.
//
// 

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS