BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//
// Class BrDbSector
//
// A rep of a BRAHMS Sector. Three so far:
//  FMS    Front Spectrometer 
//  MIDS   Mid-rapidity Spectrometer 
//  GLOBAL Global stuff

// $Author: hagel $
// $Date: 2001/06/21 14:55:16 $
// $Copyright: Brahms collaboration
// $Id: BrDbSector.cxx,v 1.1.1.1 2001/06/21 14:55:16 hagel Exp $

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

ClassImp(BrDbSector);

//____________________________________________________________________
const Char_t* BrDbSector::kTableName = SECTOR_NAME;

//____________________________________________________________________
 BrDbSector::BrDbSector(const Char_t* name)
{
  SetName(name);
}

//____________________________________________________________________
 BrDbSector* BrDbSector::SingleInstance(TSQLRow* row)
{
  if (!row) return 0;
  BrDbSector* sec = new BrDbSector(row->GetField(1)); 
  sec->SetDBID(strtol(row->GetField(0),NULL,0));
  return sec;
}

//____________________________________________________________________
 TObjArray* BrDbSector::MultipleInstance(TSQLResult* res)
{
  Int_t count = (res) ? res->GetRowCount() : 0;
  TObjArray* table = new TObjArray(count);

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

//____________________________________________________________________
 BrDbQuery* BrDbSector::Create(void) 
{
  return BrDbQuery::Create(BrDbSector::kTableName,
			   "name VARCHAR(64) NOT NULL, UNIQUE(name)");
}

//____________________________________________________________________
BrDbQuery* 
 BrDbSector::Insert(void) 
{
  return BrDbQuery::Insert(BrDbSector::kTableName, 
			   Form("%d, '%s'", GetDBID(), fName));
}

//____________________________________________________________________
void          
 BrDbSector::SetName(const Char_t* name)
{
  if (strlen(name) > 63) {
    strncpy(fName,name,63);
    fName[63] = '0';
  }
  else
    strcpy(fName,name);
}



//
// $Log: BrDbSector.cxx,v $
// Revision 1.1.1.1  2001/06/21 14:55:16  hagel
// Initial revision of brat2
//
// Revision 1.5  2001/06/05 18:41:21  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.4  2001/03/22 20:45:21  cholm
// Added protection for NULL TSqlRow in SingleInstance methods, and cleaned
// up a bit of the stuff.
//
// Revision 1.3  2000/05/10 15:56:13  nbi
// Added the classes BrRunsDb, BrGeometriesDb, changed some code, bug
// corrections , and so on. It's almost there ;-)
//
//

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