Skip to content
Snippets Groups Projects
Commit f32de834 authored by Lorenzo Moneta's avatar Lorenzo Moneta
Browse files

- return directly the status in operator int() due to a problem observed when...

- return directly the status in operator int() due to a problem observed when CINT was calling this function

- use R__ASSERT insetad of assert


git-svn-id: http://root.cern.ch/svn/root/trunk@31218 27541ba8-7e3a-0410-8455-c3a389f83636
parent 7ad3f61c
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,13 @@ class TFitResult; ...@@ -31,13 +31,13 @@ class TFitResult;
class TFitResultPtr { class TFitResultPtr {
public: public:
TFitResultPtr(int status = 0): fStatus(status), fPointer(0) {}; TFitResultPtr(int status = -1): fStatus(status), fPointer(0) {};
TFitResultPtr(TFitResult* p): fStatus(0), fPointer(p) {}; TFitResultPtr(TFitResult* p);
TFitResultPtr(const TFitResultPtr& rhs); TFitResultPtr(const TFitResultPtr& rhs);
operator int() const; operator int() const { return fStatus; }
TFitResult& operator*() const; TFitResult& operator*() const;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "TFitResultPtr.h" #include "TFitResultPtr.h"
#include "TFitResult.h" #include "TFitResult.h"
#include <cassert> #include "TError.h"
/** /**
TFitResultPtr provides an indirection to the TFitResult class and with a semantics TFitResultPtr provides an indirection to the TFitResult class and with a semantics
...@@ -24,6 +24,14 @@ The class ...@@ -24,6 +24,14 @@ The class
ClassImp(TFitResultPtr) ClassImp(TFitResultPtr)
TFitResultPtr::TFitResultPtr(TFitResult * p) :
fStatus(-1),
fPointer(p)
{
// constructor from a TFitResult pointer
if (fPointer != 0) fStatus = fPointer->Status();
}
TFitResultPtr::TFitResultPtr(const TFitResultPtr& rhs) : TFitResultPtr::TFitResultPtr(const TFitResultPtr& rhs) :
fStatus(rhs.fStatus), fPointer(0) fStatus(rhs.fStatus), fPointer(0)
{ {
...@@ -38,21 +46,12 @@ TFitResultPtr::~TFitResultPtr() ...@@ -38,21 +46,12 @@ TFitResultPtr::~TFitResultPtr()
delete fPointer; delete fPointer;
} }
TFitResultPtr::operator int() const
{
// automatic integer conversion. Needed for backward-compatibility with int TH1::FIt
// The returned integer is the fit status code from FitResult
if ( fPointer == 0 )
return fStatus;
else
return fPointer->Status();
}
TFitResult& TFitResultPtr::operator*() const TFitResult& TFitResultPtr::operator*() const
{ {
// impelment the de-reference operator to make the class acts as a pointer to a TFitResult // impelment the de-reference operator to make the class acts as a pointer to a TFitResult
// assert in case the class does not contain a pointer to TFitResult // assert in case the class does not contain a pointer to TFitResult
assert (fPointer != 0); R__ASSERT (fPointer != 0);
return *fPointer; return *fPointer;
} }
...@@ -60,7 +59,7 @@ TFitResult* TFitResultPtr::operator->() const ...@@ -60,7 +59,7 @@ TFitResult* TFitResultPtr::operator->() const
{ {
// implement the -> operator to make the class acts as a pointer to a TFitResult // implement the -> operator to make the class acts as a pointer to a TFitResult
// assert in case the class does not contain a pointer to TFitResult // assert in case the class does not contain a pointer to TFitResult
assert (fPointer != 0); R__ASSERT (fPointer != 0);
return fPointer; return fPointer;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment