BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
// 
// Class BrDbPass
//
// Rep of a Component inside and outside of Database.
// 

// $Author: cholm $
// $Date: 2001/10/08 11:00:37 $
// $Copyright: Brahms collaboration
// $Id: BrDbPass.cxx,v 1.1 2001/10/08 11:00:37 cholm Exp $
//

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

//____________________________________________________________________
ClassImp(BrDbPass);           // Pass Class for BRAHMS database

//____________________________________________________________________
const Char_t* BrDbPass::kTableName = "Pass";

//____________________________________________________________________
 BrDbPass::BrDbPass(const Char_t* name,
	       Int_t runno)
{
  SetName(name);
  fRunNo = runno;
}

//____________________________________________________________________
 BrDbPass*  BrDbPass::SingleInstance(TSQLRow* row)
{
  // Returns an instance of a BrDbPass. User needs to store this
  // object immediately. 
  if (!row) return 0;
  BrDbPass* pass = new BrDbPass(row->GetField(2),
			    strtol(row->GetField(1),NULL,0));
  pass->SetStartTime(strtol(row->GetField(3),NULL,0));
  pass->SetEndTime(strtol(row->GetField(4),NULL,0));
  pass->SetDBID(strtol(row->GetField(0),NULL,0));
  pass->SetRevisionId(strtol(row->GetField(5),NULL,0));
  return pass;
}

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

//____________________________________________________________________
 BrDbQuery* BrDbPass::Create(void) 
{
  return BrDbQuery::Create(BrDbPass::kTableName,
			  "RunNo         INT NOT NULL,
			   PassName      VARCHAR(64) NOT NULL,
			   PassStartTime INT NOT NULL,
			   PassEndTime   INT NOT NULL,
                           RevisionId    INT NOT NULL");
}

//____________________________________________________________________
 BrDbQuery* BrDbPass::Insert(void) 
{
  return BrDbQuery::Insert(BrDbPass::kTableName,
			   Form("%d, %d, '%s', %d, %d, %d", 
				GetDBID(), fRunNo,fPassName, 
				fStartTime,fEndTime,fRevisionId));
}

//____________________________________________________________________
 void BrDbPass::SetName(const Char_t* name) 
{ 
  // Set the pass name

  if (strlen(name) > 64) {
    strncpy(fPassName, name, 63);
    fPassName[63] = '0';
  }
  else 
    strcpy(fPassName, name);
}

// EOF

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