Changeset 15440 for trunk/Mars/msql


Ignore:
Timestamp:
04/25/13 14:32:54 (12 years ago)
Author:
tbretz
Message:
Support more than one MTreeSQL per database connection.
Location:
trunk/Mars/msql
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msql/MSQLServer.cc

    r15439 r15440  
    447447        if (TestBit(kIsOwner))
    448448        {
    449             if (fTree)
    450                 delete fTree;
     449            fTrees.Delete();
    451450
    452451            delete fServ;
     
    626625        fType = kIsZombie;
    627626
    628     fTree = 0;
    629627    fList.SetOwner();
    630628}
     
    720718{
    721719    fServ = serv.fServ;
    722     fTree = 0;
    723720
    724721    fDataBase = serv.fDataBase;
     
    881878}
    882879
    883 MTreeSQL *MSQLServer::GetTree(const char *table, const char *addon)
     880MTreeSQL *MSQLServer::GetTree(TString table, TString addon)
    884881{
    885882    if (fType!=kIsServer || !fServ || !TestBit(kIsOwner))
    886883        return 0;
    887884
    888     if (!fTree)
    889         fTree = new MTreeSQL(this, table, addon);
    890 
    891     return fTree;
     885    TIter Next(&fTrees);
     886    TObject *o = 0;
     887    while ((o=Next()))
     888    {
     889        if (o->GetName()==table && o->GetName()==addon)
     890            return (MTreeSQL*)o;
     891    }
     892
     893    MTreeSQL *t = new MTreeSQL(this, table, addon);
     894    fTrees.Add(t);
     895
     896    return t;
    892897}
    893898
  • trunk/Mars/msql/MSQLServer.h

    r15439 r15440  
    1818private:
    1919    TSQLServer *fServ;
    20     MTreeSQL   *fTree;
     20    TList fTrees;
    2121
    2222    TString fDataBase;
     
    6969public:
    7070    MSQLServer(TSQLServer *serv, const char *dbname=0, const char *tname=0, const char *col=0)
    71         : fServ(serv), fTree(0), fDataBase(dbname), fTable(tname), fColumn(col), fType(kIsZombie)
     71        : fServ(serv), fDataBase(dbname), fTable(tname), fColumn(col), fType(kIsZombie)
    7272    {
    7373        fList.SetOwner();
     
    131131    void RecursiveRemove(TObject *obj);
    132132
    133     MTreeSQL   *GetTree(const char *table, const char *addon=0);
     133    MTreeSQL   *GetTree(TString table, TString addon="");
    134134
    135135    ClassDef(MSQLServer, 0) // An enhancement of TSQLServer
  • trunk/Mars/msql/MTreeSQL.cc

    r15439 r15440  
    4646//______________________________________________________________________________
    4747MTreeSQL::MTreeSQL(MSQLServer *server, const TString& table, const TString &addon) :
    48     TTree(table.Data(), "Database read from table: " + table, 0),
    49     fServer(server), fQuery(table+" "+addon), fResult(0), fRow(0)
     48    TTree(table, addon, 0), fServer(server), fQuery(table+" "+addon), fResult(0), fRow(0)
    5049{
    5150    fEntries = 0;
Note: See TracChangeset for help on using the changeset viewer.