00001 #ifndef Alignment_CommonAlignment_AlignableDetOrUnitPtr_H 00002 #define Alignment_CommonAlignment_AlignableDetOrUnitPtr_H 00003 00024 class Alignable; 00025 class AlignableBeamSpot; 00026 class AlignableDet; 00027 class AlignableDetUnit; 00028 class AlignmentPositionError; 00029 00030 class AlignableDetOrUnitPtr 00031 { 00032 public: 00033 00035 inline AlignableDetOrUnitPtr(AlignableBeamSpot *aliBeamSpot) 00036 : theAliBeamSpot(aliBeamSpot), theAliDet(0), theAliDetUnit(0) {} 00037 00039 inline AlignableDetOrUnitPtr(AlignableDet *aliDet) 00040 : theAliBeamSpot(0), theAliDet(aliDet), theAliDetUnit(0) {} 00041 00043 inline AlignableDetOrUnitPtr(AlignableDetUnit *aliDetUnit) 00044 : theAliBeamSpot(0), theAliDet(0), theAliDetUnit(aliDetUnit) {} 00046 inline ~AlignableDetOrUnitPtr() {} 00047 00048 inline AlignableDetOrUnitPtr& operator = (AlignableBeamSpot* aliBeamSpot) { 00049 theAliBeamSpot = aliBeamSpot; theAliDet = 0; theAliDetUnit = 0; return *this;} 00050 inline AlignableDetOrUnitPtr& operator = (AlignableDet* aliDet) { 00051 theAliBeamSpot = 0; theAliDet = aliDet; theAliDetUnit = 0; return *this;} 00052 inline AlignableDetOrUnitPtr& operator = (AlignableDetUnit* aliDetUnit) { 00053 theAliBeamSpot = 0; theAliDet = 0; theAliDetUnit = aliDetUnit; return *this;} 00054 // Default operator= and default copy constructor are fine, no need to code them here. 00055 00056 // conversions to Alignable* etc. 00057 operator Alignable* (); 00058 operator const Alignable* () const; 00059 inline Alignable* operator->() { return this->operator Alignable*();} 00060 inline const Alignable* operator->() const { return this->operator const Alignable*();} 00061 // explicit call if needed: 00062 inline Alignable* alignable() { return this->operator Alignable*();} 00063 inline const Alignable* alignable() const { return this->operator const Alignable*();} 00064 00065 // explicit access to specific types 00066 inline AlignableBeamSpot* alignableBeamSpot() { return theAliBeamSpot;} 00067 inline const AlignableBeamSpot* alignableBeamSpot() const { return theAliBeamSpot;} 00068 inline AlignableDet* alignableDet() { return theAliDet;} 00069 inline const AlignableDet* alignableDet() const { return theAliDet;} 00070 inline AlignableDetUnit* alignableDetUnit() { return theAliDetUnit;} 00071 inline const AlignableDetUnit* alignableDetUnit() const { return theAliDetUnit;} 00072 00074 inline bool isNull() const { return (!theAliBeamSpot && !theAliDet && !theAliDetUnit);} 00075 00076 // interface to methods specific for AlignableDet(Unit), 00077 // slightly breaking idea of 'pointerness' of this class 00079 const AlignmentPositionError* alignmentPositionError() const; 00080 00081 private: 00082 AlignableBeamSpot *theAliBeamSpot; 00083 AlignableDet *theAliDet; 00084 AlignableDetUnit *theAliDetUnit; 00085 }; 00086 00087 #endif