BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
// 
// Class BrDbDetector
//
// Rep of Detector type in BRAHMS database.
//

// $Author: hagel $
// $Date: 2001/06/21 14:55:16 $
// $Copyright: BRAHMS Collabration
// $Id: BrDbDetectorType.cxx,v 1.1.1.1 2001/06/21 14:55:16 hagel Exp $

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

ClassImp(BrDbDetectorType);

//____________________________________________________________________
const Char_t* BrDbDetectorType::kTableName = DETECTORTYPE_NAME;

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

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

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

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

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

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


//
// $Log: BrDbDetectorType.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:40:28  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.4  2001/03/22 20:44:27  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:12  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