CObject Class Reference

#include <CObject.h>

Inheritance diagram for CObject:
CHistogram

List of all members.

Public Member Functions

 CObject ()
 CObject (TObject *obj, const TObject *inputsource)
 CObject (const CObject &cobj)
virtual ~CObject ()
CObjectoperator= (const CObject &obj)
const char * GetName () const
const char * GetTitle () const
Bool_t IsSortable () const
ULong_t Hash () const
Bool_t IsEqual (const TObject *obj2) const
Int_t Compare (const TObject *obj) const
TObject * GetTObject () const
const TObject * GetInputSource () const
void SetTObject (TObject *obj)
void SetInputSource (const TObject *obj)
virtual void Draw (Option_t *option="")
virtual void Paint (Option_t *option="")
virtual void ReadObject ()

Protected Attributes

TObject * fTObject
const TObject * fInputSource
TString fName

Private Member Functions

TObject * GetNewObj (const char *, const TObject *)
void free ()
void ResetAllkCanDelete (TVirtualPad *pad)

Detailed Description

Definition at line 24 of file CObject.h.


Constructor & Destructor Documentation

CObject::CObject (  ) 

Definition at line 40 of file CObject.cxx.

00040 :TObject() {}

CObject::CObject ( TObject *  obj,
const TObject *  inputsource 
)

Definition at line 42 of file CObject.cxx.

References fName, and fTObject.

00042                                                          :
00043   fTObject(obj), fInputSource(inputsource) {
00044 
00045   if ( fTObject ) fName = fTObject->GetName();
00046 }

CObject::CObject ( const CObject cobj  ) 

Definition at line 48 of file CObject.cxx.

References fName, and fTObject.

00048                                     :
00049   TObject(cobj), fTObject(cobj.fTObject), fInputSource(cobj.fInputSource) {
00050 
00051   if ( fTObject ) fName = fTObject->GetName();
00052 }

CObject::~CObject (  )  [virtual]

Definition at line 55 of file CObject.cxx.

References free().

00056 {
00057   free();
00058 }


Member Function Documentation

Int_t CObject::Compare ( const TObject *  obj  )  const

Definition at line 89 of file CObject.cxx.

References GetName().

00090 {
00091   if (this == obj) return 0;
00092   if (CObject::Class() != obj->IsA()) return -1;
00093   return TString(GetName()).CompareTo(obj->GetName());
00094 }

void CObject::Draw ( Option_t *  option = ""  )  [virtual]

Reimplemented in CHistogram.

Definition at line 106 of file CObject.cxx.

References fTObject.

00107 {
00108   if ( ! fTObject ) return;
00109 
00110   ResetBit( kCanDelete );
00111   AppendPad( option );
00112 
00113 }

void CObject::free (  )  [private]

Reimplemented in CHistogram.

Definition at line 199 of file CObject.cxx.

References fTObject, and ResetAllkCanDelete().

Referenced by SetTObject(), and ~CObject().

00200 {
00201   //cout << " In CObject free " << endl;
00202   if ( !fTObject ) return;
00203 
00204   if ( fTObject->InheritsFrom( TPad::Class() ) )
00205     ResetAllkCanDelete( (TPad*)fTObject );
00206 
00207   delete fTObject;
00208   fTObject = 0;
00209 
00210 }

const TObject* CObject::GetInputSource (  )  const [inline]
const char * CObject::GetName (  )  const

Definition at line 60 of file CObject.cxx.

References fName.

Referenced by Compare(), and ReadObject().

00061 { 
00062   return fName.Data();
00063 }

TObject * CObject::GetNewObj ( const char *  objName,
const TObject *  inputobj 
) [private]

Definition at line 130 of file CObject.cxx.

References count.

Referenced by ReadObject().

00131 {
00132 
00133   //cout << " In GetNewObj" << endl;
00134 
00135   TObject *obj = 0;
00136 
00137   if (inputobj) {
00138 
00139     if ( inputobj->IsA() == TMapFile::Class() ) {
00140       TMapFile *mfile = (TMapFile*)inputobj;
00141       if (mfile) obj = (TObject*)mfile->Get( objName );
00142     }
00143     else if ( inputobj->IsA() == TFile::Class() ) {
00144       TFile *rfile = (TFile*)inputobj;
00145       if (rfile) obj = (TObject*)rfile->Get( objName );
00146     }
00147     else if ( inputobj->IsA() == TSocket::Class() ) {
00148       TSocket *socket = (TSocket*)inputobj;
00149 
00150       if ( socket && socket->IsValid() ) {
00151 
00152         Int_t count = 0;
00153         Int_t maxcount = 5;
00154 
00155         while ( !obj && count < maxcount ) {
00156 
00157           socket->Send( objName );
00158           TMessage *message = NULL;
00159           socket->Recv(message);
00160           if ( message && message->What() == kMESS_OBJECT) {
00161             obj = (TObject*)message->ReadObject(message->GetClass());
00162           }
00163           delete message;
00164 
00165           count++;
00166         } //while ( !obj && count < maxcount )
00167 
00168 
00169         if ( ! obj ) {
00170           cout << " Failed to get " << objName
00171                << " after " << maxcount << " tries." << endl;
00172         } //if ( ! obj )
00173         else {
00174           if ( count > 1 ) cout << " The object " << objName
00175                                 << " is sent from the socket by " << count
00176                                 << " tries." << endl;
00177         } //else of if ( ! obj )
00178 
00179       } //if ( socket && socket->IsValid() )
00180       else {
00181         cout << "no connection to socket..." << endl;
00182       } //else // if ( socket && socket->IsValid() )
00183 
00184     } // TMapFile,TFile, TSocket
00185 
00186     else {
00187 
00188       cout << " No inputobj " << endl;
00189 
00190     } // else // TMapFile,TFile, TSocket
00191 
00192   } // if(inputobj)
00193 
00194   return obj;
00195 
00196 }

const char* CObject::GetTitle (  )  const [inline]

Definition at line 48 of file CObject.h.

References fTObject.

Referenced by HistoDisplay::GetCObjFromListItem(), and HistoDisplay::RefreshTreeItem().

00048 { return fTObject->GetTitle(); };

TObject* CObject::GetTObject (  )  const [inline]
ULong_t CObject::Hash (  )  const

Definition at line 65 of file CObject.cxx.

References fTObject.

00066 {
00067   if ( fTObject ) return fTObject->Hash();
00068   else return 0;
00069 }

Bool_t CObject::IsEqual ( const TObject *  obj2  )  const

Definition at line 72 of file CObject.cxx.

References fTObject.

00073 {
00074   //if ( !obj2 || ! obj2->InheritsFrom(CObject::Class()) ) return kFALSE;
00075   //return fTObject->IsEqual(((CObject*)obj2)->GetTObject());
00076   if ( obj2 && obj2->InheritsFrom( CObject::Class() ) ) {
00077     if ( fTObject &&
00078          fTObject->IsEqual( ((CObject*)obj2)->GetTObject() ) )
00079       return kTRUE;
00080     else return kFALSE;
00081   }
00082   else {
00083     return kFALSE;
00084   }
00085 
00086 }

Bool_t CObject::IsSortable (  )  const [inline]

Definition at line 50 of file CObject.h.

00050 {return kTRUE; }

CObject & CObject::operator= ( const CObject obj  ) 

Reimplemented in CHistogram.

Definition at line 231 of file CObject.cxx.

References fInputSource, fTObject, and SetTObject().

00232 {
00233   if (this != &cobj) {
00234     //if ( fTObject ) delete fTObject;
00235     //fTObject = cobj.fTObject;
00236     SetTObject( cobj.fTObject );
00237     fInputSource = cobj.fInputSource;
00238   }
00239   return *this;
00240 }

void CObject::Paint ( Option_t *  option = ""  )  [virtual]

Reimplemented in CHistogram.

Definition at line 115 of file CObject.cxx.

References fTObject.

00116 {
00117   if ( ! fTObject ) return;
00118   fTObject->Paint( option );
00119 }

void CObject::ReadObject (  )  [virtual]

Definition at line 123 of file CObject.cxx.

References fInputSource, GetName(), GetNewObj(), and SetTObject().

00124 {
00125   SetTObject( GetNewObj( GetName(), fInputSource ) );
00126 }

void CObject::ResetAllkCanDelete ( TVirtualPad *  pad  )  [private]

Definition at line 213 of file CObject.cxx.

Referenced by free().

00214 {
00215   if ( !pad ) return;
00216 
00217   TObjLink *link = pad->GetListOfPrimitives()->FirstLink();
00218 
00219   while( link ) {
00220     TObject *obj = link->GetObject();
00221     if ( obj ) { 
00222       if ( ! obj->TestBit( kCanDelete ) ) obj->SetBit( kCanDelete );
00223       if ( obj->InheritsFrom( TPad::Class() ) ) 
00224         ResetAllkCanDelete( (TPad*) obj );
00225     }
00226     link = link->Next();
00227   } // while( link )
00228 
00229 }

void CObject::SetInputSource ( const TObject *  obj  )  [inline]

Definition at line 62 of file CObject.h.

References fInputSource.

Referenced by HistoDisplay::GetCObjFromListItem(), and HistoDisplay::UpdateHistoList().

00062 { fInputSource = obj; }

void CObject::SetTObject ( TObject *  obj  ) 

Definition at line 97 of file CObject.cxx.

References free(), and fTObject.

Referenced by HistoDisplay::AddPadHistosToHistoList(), operator=(), ReadObject(), and HistoDisplay::UpdateHistoList().

00098 {
00099   if ( fTObject != obj ) {
00100     free();
00101     fTObject = obj;
00102   } //if ( fTObject != obj )
00103 }


Member Data Documentation

const TObject* CObject::fInputSource [protected]

Definition at line 33 of file CObject.h.

Referenced by CHistogram::copy(), GetInputSource(), operator=(), ReadObject(), and SetInputSource().

TString CObject::fName [protected]

Definition at line 34 of file CObject.h.

Referenced by CObject(), and GetName().

TObject* CObject::fTObject [protected]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1