Ignore:
Timestamp:
04/06/04 13:41:56 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r3574 r3666  
    407407TMethodCall *MParContainer::GetterMethod(const char *name) const
    408408{
    409     TClass *cls = IsA()->GetBaseDataMember(name);
     409    const TString n(name);
     410    const Int_t pos1 = n.First('.');
     411
     412    const TString part1 = pos1<0 ? n : n(0, pos1);
     413    const TString part2 = pos1<0 ? TString("") : n(pos1+1, n.Length());
     414
     415    TClass *cls = IsA()->GetBaseDataMember(part1);
    410416    if (cls)
    411417    {
    412         TDataMember *member = cls->GetDataMember(name);
     418        TDataMember *member = cls->GetDataMember(part1);
    413419        if (!member)
    414420        {
    415             *fLog << err << "Datamember '" << name << "' not in " << GetDescriptor() << endl;
     421            *fLog << err << "Datamember '" << part1 << "' not in " << GetDescriptor() << endl;
    416422            return NULL;
     423        }
     424
     425        // This handles returning references of contained objects, eg
     426        // class X { TObject fO; TObject &GetO() { return fO; } };
     427        if (!member->IsBasic() && !part2.IsNull())
     428        {
     429            cls = gROOT->GetClass(member->GetTypeName());
     430            if (!cls)
     431            {
     432                *fLog << err << "Datamember " << part1 << " [";
     433                *fLog << member->GetTypeName() << "] not in dictionary." << endl;
     434                return NULL;
     435            }
     436            if (!cls->InheritsFrom(MParContainer::Class()))
     437            {
     438                *fLog << err << "Datamember " << part1 << " [";
     439                *fLog << member->GetTypeName() << "] does not inherit from ";
     440                *fLog << "MParContainer." << endl;
     441                return NULL;
     442            }
     443
     444            const MParContainer *sub = (MParContainer*)((ULong_t)this+member->GetOffset());
     445            return sub->GetterMethod(part2);
     446        }
     447
     448        if (member->IsaPointer())
     449        {
     450            *fLog << warn << "Data-member " << part1 << " is a pointer..." << endl;
     451            *fLog << dbginf << "Not yet implemented!" << endl;
     452            //TClass *test = gROOT->GetClass(member->GetTypeName());
     453            return 0;
    417454        }
    418455
     
    422459    }
    423460
    424     *fLog << warn << "No standard access for '" << name << "' in ";
     461    *fLog << warn << "No standard access for '" << part1 << "' in ";
    425462    *fLog << GetDescriptor() << " or one of its base classes." << endl;
    426463
     
    428465
    429466    *fLog << warn << "Trying to find MethodCall '" << ClassName();
    430     *fLog << "::Get" << name << "' instead <LEAKS MEMORY>" << endl;
    431     call = new TMethodCall(IsA(), (TString)"Get"+name, "");
     467    *fLog << "::Get" << part1 << "' instead <LEAKS MEMORY>" << endl;
     468    call = new TMethodCall(IsA(), (TString)"Get"+part1, "");
    432469    if (call->GetMethod())
    433470        return call;
     
    436473
    437474    *fLog << warn << "Trying to find MethodCall '" << ClassName();
    438     *fLog << "::" << name << "' instead <LEAKS MEMORY>" << endl;
    439     call = new TMethodCall(IsA(), name, "");
     475    *fLog << "::" << part1 << "' instead <LEAKS MEMORY>" << endl;
     476    call = new TMethodCall(IsA(), part1, "");
    440477    if (call->GetMethod())
    441478        return call;
     
    443480    delete call;
    444481
    445     *fLog << err << "Sorry, no getter method found for " << name << endl;
     482    *fLog << err << "Sorry, no getter method found for " << part1 << endl;
    446483    return NULL;
    447484}
Note: See TracChangeset for help on using the changeset viewer.