Thanks Lorenzo! I must admit I’m still a little confused. Does the lack of a dictionary mean that I can’t call the function, or just that I can’t call it from within an interactive session? I’ve tried in an interactive session with:
and
and neither works.
I’m also having trouble getting the Streamer to work. Compiling with ACLiC I get the following errors from the automatically generated Streamer in the dictionary:
[quote]/Applications/root/ROOTUtils/TFitFunction/tmp_0_pe4ZTP.cxx: In member function ‘virtual void TCompoundFormula::Streamer(TBuffer&)’:
/Applications/root/ROOTUtils/TFitFunction/tmp_0_pe4ZTP.cxx:464: error: type ‘class std::vector<TF1*, std::allocator<TF1*> >’ argument given to ‘delete’, expected pointer
/Applications/root/ROOTUtils/TFitFunction/tmp_0_pe4ZTP.cxx:465: error: no match for ‘operator=’ in '((TCompoundFormula)this)->TCompoundFormula::fComps = (((const std::allocator<TF1*>&)((const std::allocator<TF1*>)(& std::allocator<TF1>()))), (((std::vector<TF1*, std::allocator<TF1*> >)operator new(12u)), (->std::vector<_Tp, _Alloc>::vector with _Tp = TF1*, _Alloc = std::allocator<TF1*>, )))’
/usr/include/gcc/darwin/4.0/c++/bits/vector.tcc:133: note: candidates are: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = TF1, _Alloc = std::allocator<TF1*>]
/Applications/root/ROOTUtils/TFitFunction/tmp_0_pe4ZTP.cxx:466: error: no match for ‘operator*’ in ‘((TCompoundFormula*)this)->TCompoundFormula::fComps’
/Applications/root/ROOTUtils/TFitFunction/tmp_0_pe4ZTP.cxx:490: error: no match for ‘operator*’ in '((TCompoundFormula*)this)->TCompoundFormula::fComps’
[/quote]
The streamer method looks like:
[code]void TCompoundFormula::Streamer(TBuffer &R__b)
{
// Stream an object of class TCompoundFormula.
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
TF1::Streamer(R__b);
{
delete fComps;
fComps = new vector<TF1>;
vector<TF1> &R__stl = fComps;
R__stl.clear();
TClass R__tcl1 = TBuffer::GetClass(typeid(TF1));
if (R__tcl1==0) {
Error(“fComps streamer”,“Missing the TClass object for TF1!”);
return;
}
int R__i, R__n;
R__b >> R__n;
R__stl.reserve(R__n);
for (R__i = 0; R__i < R__n; R__i++) {
TF1 R__t;
R__t = (TF1)R__b.ReadObjectAny(R__tcl1);
R__stl.push_back(R__t);
}
}
R__b >> fCombination;
R__b >> fDummyFormula;
R__b >> fNumPars;
R__b.CheckByteCount(R__s, R__c, TCompoundFormula::IsA());
} else {
R__c = R__b.WriteVersion(TCompoundFormula::IsA(), kTRUE);
TF1::Streamer(R__b);
{
vector<TF1> &R__stl = *fComps;
int R__n=(&R__stl) ? int(R__stl.size()) : 0;
R__b << R__n;
if(R__n) {
vector<TF1>::iterator R__k;
for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
R__b << (*R__k);
}
}
}
R__b << fCombination;
R__b << fDummyFormula;
R__b << fNumPars;
R__b.SetByteCount(R__c, kTRUE);
}
}
[/code]
I tried making a very simple test class with just a pointer to vector of TF1*s as a data member (this is exactly the same context as the vector int the non-compiling class) and this compiles fine. Its streamer looks like:
[code]void Test::Streamer(TBuffer &R__b)
{
// Stream an object of class Test.
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
TObject::Streamer(R__b);
{
delete formulae;
formulae = new vector<TF1>;
vector<TF1> &R__stl = formulae;
R__stl.clear();
TClass R__tcl1 = TBuffer::GetClass(typeid(TF1));
if (R__tcl1==0) {
Error(“formulae streamer”,“Missing the TClass object for TF1!”);
return;
}
int R__i, R__n;
R__b >> R__n;
R__stl.reserve(R__n);
for (R__i = 0; R__i < R__n; R__i++) {
TF1 R__t;
R__t = (TF1)R__b.ReadObjectAny(R__tcl1);
R__stl.push_back(R__t);
}
}
R__b.CheckByteCount(R__s, R__c, Test::IsA());
} else {
R__c = R__b.WriteVersion(Test::IsA(), kTRUE);
TObject::Streamer(R__b);
{
vector<TF1> &R__stl = *formulae;
int R__n=(&R__stl) ? int(R__stl.size()) : 0;
R__b << R__n;
if(R__n) {
vector<TF1>::iterator R__k;
for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
R__b << (*R__k);
}
}
}
R__b.SetByteCount(R__c, kTRUE);
}
}
[/code]
To my untrained eye, the portions pertaining to the vectors (fComps and formulae respectively) appear identical, and the error messages seem to originate from the streaming of the vector, so I’m a little bemused as to why one should compile and the other not.
Any ideas?
Hugh