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

//
// $Id: BrDbShiftReport.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 <BrDbShiftReport.h>
#ifndef BRAT_BrException
#include "BrException.h"
#endif
#ifndef WIN32 
#include <cstdlib>
#include <iostream>
#else 
#include <cstdlib>
#include <iostream.h>
#endif
#include <TString.h>
#include <iostream.h>
#include <iomanip.h>
#include <time.h>

ClassImp(BrDbShiftReport);
 
//____________________________________________________________________
const Char_t* BrDbShiftReport::kTableName = "ShiftReports";

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

//____________________________________________________________________
 BrDbShiftReport::BrDbShiftReport(Int_t   time,
				 Int_t   logBook,
				 Int_t   logPage1,
				 Int_t   logPage2,
				 const Char_t* shift,    
				 const Char_t* shiftSupervisor,
				 const Char_t* shiftPersonel,
				 const Char_t* shiftSummary)
{
  // Constructor.
  fTime      = time;
  fLogBook   = logBook;
  fLogPage1  = logPage1;   
  fLogPage2  = logPage2;   
  SetShift(shift);    
  SetShiftSupervisor(shiftSupervisor);
  SetShiftPersonel(shiftPersonel);
  SetShiftSummary(shiftSummary);

  SetDBID(time);
}

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

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

//____________________________________________________________________
 BrDbShiftReport* BrDbShiftReport::SingleInstance(TSQLRow* row)
{
  // Returns an instance of a BrDbShiftReport. User needs to store this
  // object imidiatly. 
  if (!row) return 0;
  BrDbShiftReport* shift = new
    BrDbShiftReport(strtol(row->GetField(0),NULL,0), 
		    strtol(row->GetField(1),NULL,0), 
		    strtol(row->GetField(2),NULL,0), 
		    strtol(row->GetField(3),NULL,0), 
		    row->GetField(4),
		    row->GetField(5),
		    row->GetField(6),
		    row->GetField(7));
  return shift;
}

//____________________________________________________________________
 TObjArray* BrDbShiftReport::MultipleInstance(TSQLResult* res)
{
  // Returns an (1D) array of BrDbShiftReport'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(BrDbShiftReport::SingleInstance(res->Next()));
  
  return table;
}

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

//____________________________________________________________________
 void BrDbShiftReport::SetShift(const Char_t* x) {
  // Set ShiftReportType
  if (strlen(x) > 256) {
    strncpy(fShift, x, 255);
    fShift[255] = '0';
  } else 
    strcpy(fShift, x);
}

//____________________________________________________________________
 void BrDbShiftReport::SetShiftSupervisor(const Char_t* x) {
  // Set ShiftReportType
  if (strlen(x) > 256) {
    strncpy(fShiftSupervisor, x, 255);
    fShiftSupervisor[255] = '0';
  } else 
    strcpy(fShiftSupervisor, x);
}

//____________________________________________________________________
 void BrDbShiftReport::SetShiftPersonel(const Char_t* x) {
  // Set ShiftReportType
  if (strlen(x) > 256) {
    strncpy(fShiftPersonel, x, 255);
    fShiftPersonel[255] = '0';
  } else 
    strcpy(fShiftPersonel, x);
}

//____________________________________________________________________
 void BrDbShiftReport::SetShiftSummary(const Char_t* x) {
  // Set ShiftSummary
  fSummarySize = strlen(x) + 1;
  if (fShiftSummary) 
    delete [] fShiftSummary;
  fShiftSummary = new Char_t[fSummarySize];
  strcpy(fShiftSummary, x);
  fShiftSummary[fSummarySize-1] = '0';
}

//____________________________________________________________________
 void BrDbShiftReport::Print(Option_t* option) 
{
  // Print shift report to standard out 
  // Options:
  //   S       Show summary (not default)
  // 
  TString opt(option);
  opt.ToLower();

  cout << "Shift at:    "  << ctime((time_t*)&fTime) << endl
       << " Log Book:   " << setw(5) << fLogBook << flush;
  if (fLogPage1 == fLogPage2) 
    cout << " p. " << setw(5) << fLogPage1 << endl;
  else
    cout << " pp. " << setw(5) << fLogPage1 
	 << " - " << setw(5) << fLogPage2  << endl;
  cout << " Shift:      " << fShift << endl
       << " Supervisor: " << fShiftSupervisor << endl
       << " Personel:   " << fShiftPersonel << endl;
  if (opt.Contains("S"))
    cout << " Summary:    " << endl << fShiftSummary << endl;
  cout << endl;
}

//____________________________________________________________________



//
// $Log: BrDbShiftReport.cxx,v $
// Revision 1.1.1.1  2001/06/21 14:55:17  hagel
// Initial revision of brat2
//
// Revision 1.3  2001/06/05 18:41:26  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.2  2001/03/22 20:45:27  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:58  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