00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: TrkExtInterface.cxx,v 1.1.1.1 2005/04/21 06:01:42 zhangy Exp $ 00004 // 00005 // Description: 00006 // 00007 // 00008 // Environment: 00009 // Software developed for the BaBar Detector at the SLAC B-Factory. 00010 // 00011 // Author(s): Steve Schaffner 00012 // 00013 //------------------------------------------------------------------------ 00014 00015 //#include "BaBar/BaBar.h" 00016 #include "TrkBase/TrkExtInterface.h" 00017 #include "TrkBase/TrkRep.h" 00018 #include "ProxyDict/IfdIntKey.h" 00019 //#include "ErrLogger/ErrLog.h" 00020 00021 //------------------------------------------------------------------------ 00022 TrkExtInterface::TrkExtInterface() : _myRep(0), _nonconst(false){ 00023 //------------------------------------------------------------------------ 00024 } 00025 00026 //------------------------------------------------------------------------ 00027 TrkExtInterface::~TrkExtInterface() { 00028 //------------------------------------------------------------------------ 00029 } 00030 00031 00032 //------------------------------------------------------------------------ 00033 bool 00034 TrkExtInterface::attach(TrkRep* newRep) { 00035 //------------------------------------------------------------------------ 00036 bool retval(false); 00037 if (myKey() == newRep->myKey()) { 00038 setRep(newRep); 00039 retval = true; 00040 } 00041 return retval; 00042 } 00043 00044 //------------------------------------------------------------------------ 00045 bool 00046 TrkExtInterface::attach(const TrkRep* newRep) { 00047 //------------------------------------------------------------------------ 00048 bool retval(false); 00049 if (myKey() == newRep->myKey()) { 00050 setRep(newRep); 00051 retval = true; 00052 } 00053 return retval; 00054 } 00055 00056 void 00057 TrkExtInterface::setRep(const TrkRep* newRep) { 00058 _myRep = (TrkRep*) newRep; 00059 _nonconst = false; 00060 } 00061 00062 void 00063 TrkExtInterface::setRep(TrkRep* newRep) { 00064 _myRep = newRep; 00065 _nonconst = true; 00066 } 00067 00068 //------------------------------------------------------------------------ 00069 TrkRep* 00070 TrkExtInterface::myRep() { 00071 //------------------------------------------------------------------------ 00072 if(_myRep != 0 && _nonconst) 00073 return _myRep; 00074 else if (0 == _myRep) { 00075 std::cout<<"ErrMsg(error) "<< "Cannot use interface without attached rep." 00076 << std::endl; 00077 return 0; 00078 } else 00079 std::cout<<"ErrMsg(error) "<< "Cannot return non-const rep after const attachment" 00080 << std::endl; 00081 return 0; 00082 } 00083 00084 //------------------------------------------------------------------------ 00085 const TrkRep* 00086 TrkExtInterface::myConstRep() const { 00087 //------------------------------------------------------------------------ 00088 if (0 == _myRep) { 00089 std::cout<<"ErrMsg(error) "<< "Cannot use interface without attached rep." 00090 << std::endl; 00091 return 0; 00092 } 00093 return _myRep; 00094 } 00095