|
// // Class BrDbRevisionType // // Rep of a RevisionType inside and outside of Database. // // $Author: cholm $ // $Date: 2001/10/08 10:41:06 $ // $Copyright: Brahms collaboration // $Id: BrDbRevisionType.cxx,v 1.2 2001/10/08 10:41:06 cholm Exp $ #include <BrDbRevisionType.h> #ifndef BRAT_BrException #include "BrException.h" #endif #ifndef WIN32 #include <cstdlib> #include <iostream> #else #include <cstdlib> #include <iostream.h> #endif ClassImp(BrDbRevisionType); // RevisionType Class for BRAHMS database //____________________________________________________________________ const Char_t* BrDbRevisionType::kTableName = REVISIONTYPE_NAME; //____________________________________________________________________ BrDbRevisionType::BrDbRevisionType(const Char_t* name, const Char_t* comment) { SetName(name); SetComment(comment); } //____________________________________________________________________ BrDbRevisionType* BrDbRevisionType::SingleInstance(TSQLRow* row) { // Returns an instance of a BrDbRevisionType. User needs to store // this object imidiatly. if (!row) return 0; BrDbRevisionType* revisionType = new BrDbRevisionType(row->GetField(1), row->GetField(2)); revisionType->SetDBID(strtol(row->GetField(0),NULL,0)); return revisionType; } //____________________________________________________________________ TObjArray* BrDbRevisionType::MultipleInstance(TSQLResult* res) { // Returns an (1D) array of BrDbRevisionTypes 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(BrDbRevisionType::SingleInstance(res->Next())); return table; } //____________________________________________________________________ BrDbQuery* BrDbRevisionType::Create(void) { return BrDbQuery::Create(BrDbRevisionType::kTableName, " name VARCHAR(64) NOT NULL," " comment VARCHAR(255)," " UNIQUE(name)"); } //____________________________________________________________________ BrDbQuery* BrDbRevisionType::Insert(void) { return BrDbQuery::Insert(BrDbRevisionType::kTableName, Form("%d, '%s', '%s'", GetDBID(), fName, fComment)); } //____________________________________________________________________ void BrDbRevisionType::SetName(const Char_t* name) { int len = strlen(name); strncpy(fName,name, (len > 255)? 255: len); } //____________________________________________________________________ void BrDbRevisionType::SetComment(const Char_t* comment) { int len = strlen(comment); strncpy(fComment,comment, (len > 255)? 255: len); } // EOF |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|