|
// // Class ComponentType // // Rep of Component types in the BRAHMS database // // $Author: hagel $ // $Date: 2001/06/21 14:55:16 $ // $Copyright: Brahms collaboration // $Id: BrDbComponentType.cxx,v 1.1.1.1 2001/06/21 14:55:16 hagel Exp $ #include <BrDbComponentType.h> #ifndef BRAT_BrException #include "BrException.h" #endif #ifndef WIN32 #include <stdlib.h> #else #include <cstdlib> #endif ClassImp(BrDbComponentType); //____________________________________________________________________ const Char_t* BrDbComponentType::kTableName = COMPONENTTYPE_NAME; //____________________________________________________________________ BrDbComponentType::BrDbComponentType(const Char_t* name) { SetName(name); } //____________________________________________________________________ BrDbComponentType* BrDbComponentType::SingleInstance(TSQLRow* row) { if (!row) return 0; BrDbComponentType* type = new BrDbComponentType(row->GetField(1)); type->SetDBID(strtol(row->GetField(0),NULL,0)); return type; } //____________________________________________________________________ TObjArray* BrDbComponentType::MultipleInstance(TSQLResult* res) { // Returns an (1D) array of BrDbComponentType 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(BrDbComponentType::SingleInstance(res->Next())); return table; } //____________________________________________________________________ BrDbQuery* BrDbComponentType::Create(void) { return BrDbQuery::Create(BrDbComponentType::kTableName, "name VARCHAR(64) NOT NULL, UNIQUE(name)"); } //____________________________________________________________________ BrDbQuery* BrDbComponentType::Insert(void) { return BrDbQuery::Insert(BrDbComponentType::kTableName, Form("%d, '%s'", GetDBID(), GetName())); } //____________________________________________________________________ void BrDbComponentType::SetName(const Char_t* name) { if (strlen(name) > 63) { strncpy(fName,name,63); fName[63] = '0'; } else strcpy(fName, name); } // // $Log: BrDbComponentType.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:14 cholm // Removed BrDbInc.h an all references to it // // Revision 1.4 2001/03/22 20:44:08 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>
|