|
//____________________________________________________________________ // // // //____________________________________________________________________ // // $Id: BrDbDb.cxx,v 1.1 2001/10/08 10:54:44 cholm Exp $ // $Author: cholm $ // $Date: 2001/10/08 10:54:44 $ // $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #ifndef BRAT_BrDbDb #include "BrDbDb.h" #endif #ifndef __CSTDLIB__ #include <cstdlib> #endif //____________________________________________________________________ ClassImp(BrDbDb); //____________________________________________________________________ const Char_t* BrDbDb::kTableName = DB_NAME; //____________________________________________________________________ BrDbDb::BrDbDb(const Char_t* name, const Char_t* host, const Char_t* file, const Char_t* type="mysql") { // Default constructor SetName(name); SetHost(host); SetFile(file); SetType(type); } //____________________________________________________________________ BrDbQuery* BrDbDb::Create() { #if 0 return new BrDbQuery(Form("CREATE TABLE %s " "(id INT NOT NULL, " " name VARCHAR(64) NOT NULL, " " host VARCHAR(64) NOT NULL, " " file VARCHAR(64) NOT NULL, " " type VARCHAR(16) NOT NULL, " " UNIQUE(id))", BrDbDb::kTableName)); #else return new BrDbQuery(Form("CREATE TABLE %s " "(name VARCHAR(64) NOT NULL, " " host VARCHAR(64) NOT NULL, " " file VARCHAR(64) NOT NULL, " " UNIQUE(name))", BrDbDb::kTableName)); #endif } //____________________________________________________________________ BrDbDb* BrDbDb::SingleInstance(TSQLRow* row) { #if 0 BrDbDb* db = new BrDbDb(row->GetField(1), // name row->GetField(2), // host row->GetField(3), // file row->GetField(4)); // type db->SetDBID(::strtol(row->GetField(0),NULL,0)); #else BrDbDb* db = new BrDbDb(row->GetField(0), // name row->GetField(1), // host row->GetField(2)); // file #endif return db; } //____________________________________________________________________ TObjArray* BrDbDb::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(BrDbDb::SingleInstance(res->Next())); return table; } //____________________________________________________________________ BrDbQuery* BrDbDb::Insert() { #if 0 return BrDbQuery::Insert(BrDbDb::kTableName, Form("'%s', '%s', '%s'", fName, fHost, fFile)); #else return BrDbQuery::Insert(BrDbDb::kTableName, Form("%d, '%s', '%s', '%s', '%s'", GetDBID(), fName, fHost, fFile, fType)); #endif } //____________________________________________________________________ void BrDbDb::SetName(const Char_t* name) { if (::strlen(name) > 63) { ::strncpy(fName, name, 63); fName[63] = '0'; } else ::strcpy(fName, name); } //____________________________________________________________________ void BrDbDb::SetHost(const Char_t* host) { if (::strlen(host) > 63) { ::strncpy(fHost, host, 63); fHost[63] = '0'; } else ::strcpy(fHost, host); } //____________________________________________________________________ void BrDbDb::SetFile(const Char_t* file) { if (::strlen(file) > 63) { ::strncpy(fFile, file, 63); fFile[63] = '0'; } else ::strcpy(fFile, file); } //____________________________________________________________________ void BrDbDb::SetType(const Char_t* type) { if (::strlen(type) > 15) { ::strncpy(fType, type, 15); fType[15] = '0'; } else ::strcpy(fType, type); } //____________________________________________________________________ // // $Log: BrDbDb.cxx,v $ // Revision 1.1 2001/10/08 10:54:44 cholm // Added the pure table representation BrDbDb of BrahmsMain.DB, rather than // the misuse of BrDb. Also added MySQL and ROOT implmentations of the // access. // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|