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

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

ClassImp(BrDbMagnet);
 
//____________________________________________________________________
const Char_t* BrDbMagnet::kTableName = "ConditionsBrahmsMagnets";

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

//____________________________________________________________________
 BrDbMagnet::BrDbMagnet(Int_t    time,    
		       Int_t    magnet,  
		       const Char_t*  polarity,
		       Float_t  setpoint,
		       const Char_t*  status)
{
  // Constructor.
  fTime     = time;
  fMagnet   = magnet;
  SetPolarity(polarity);
  fSetpoint = setpoint;
  SetStatus(status);

  SetDBID(time);
}

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

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

//____________________________________________________________________
BrDbMagnet*  
 BrDbMagnet::SingleInstance(TSQLRow* row)
{
  // Returns an instance of a BrDbMagnet. User needs to store this
  // object imidiatly. 
  if (!row) return 0;
  BrDbMagnet* magnet = 
    new BrDbMagnet(strtol(row->GetField(0),NULL,0),  // Time
		   strtol(row->GetField(1),NULL,0),  // Magnet
		   row->GetField(2),                 // Polarity
		   strtod(row->GetField(3),NULL),    // Setpoint
		   row->GetField(4));                // Status 
  return magnet;
}

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

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

//____________________________________________________________________
 void BrDbMagnet::SetPolarity(const Char_t* polarity) {
  // Set MagnetType
  if (strlen(polarity) > 256) {
    strncpy(fPolarity, polarity, 255);
    fPolarity[255] = '0';
  } else 
    strcpy(fPolarity, polarity);
}

//____________________________________________________________________
 void BrDbMagnet::SetStatus(const Char_t* status) {
  // Set MagnetType
  if (strlen(status) > 256) {
    strncpy(fStatus, status, 255);
    fStatus[255] = '0';
  } else 
    strcpy(fStatus, status);
}
//____________________________________________________________________



//
// $Log: BrDbMagnet.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:40:40  cholm
// Removed BrDbInc.h an all references to it
//
// Revision 1.2  2001/03/22 20:44:37  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:53  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