00001 #ifndef DCHAIN_LABELEDCANDIDATE_H 00002 #define DCHAIN_LABELEDCANDIDATE_H 00003 // -*- C++ -*- 00004 // 00005 // Package: DChain 00006 // Module: LabeledCandidate 00007 // 00008 // Description: pairing of subclass of Candidate and Conjugation::Label 00009 // 00010 // Usage: 00011 // <usage> 00012 // 00013 // Author: Simon Patton 00014 // Created: Wed Sep 18 14:47:30 EDT 1996 00015 // $Id: LabeledCandidate.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $: LabeledCandidate.h,v 1.6 1997/08/19 23:01:45 sjp Exp $ 00016 // 00017 // Revision history 00018 // 00019 // $Log: LabeledCandidate.h,v $ 00020 // Revision 1.1.1.1 2009/03/03 06:06:56 maqm 00021 // first import of DecayChain 00022 // 00023 // Revision 1.1 2006/01/11 20:28:08 cdj 00024 // massive class renaming, addition of [] for selection and unit tests 00025 // 00026 // 00027 00028 // system include files 00029 00030 // user include files 00031 #include "DecayChain/Element/conjugation.h" // enumerator 00032 #include "DecayChain/Element/ReferenceHolder.h" 00033 00034 // forward declarations 00035 namespace dchain { 00036 template < class CandidateClass > 00037 class LabeledCandidate 00038 { 00039 // friend classses and functions 00040 00041 public: 00042 // constants, enums and typedefs 00043 00044 // Constructors and destructor 00045 LabeledCandidate() {} 00046 LabeledCandidate( const LabeledCandidate< CandidateClass >& aOtherLabeled ) : 00047 m_pointer( aOtherLabeled.m_pointer ) , 00048 m_label( aOtherLabeled.m_label ) 00049 {} 00050 virtual ~LabeledCandidate() {} 00051 00052 // assignment operator(s) 00053 const LabeledCandidate& operator=( const LabeledCandidate< CandidateClass >& aOtherLabeled ) 00054 { 00055 m_pointer = aOtherLabeled.m_pointer ; 00056 m_label = aOtherLabeled.m_label ; 00057 return ( *this ) ; 00058 } 00059 00060 00061 // member functions 00062 00063 // const member functions 00064 // note: The following function can NOT be virtual as its return type changes 00065 // for CandidateClasses 00066 const CandidateClass& operator()() const { 00067 return ( *m_pointer ) ; 00068 } 00069 00070 // 00071 const CandidateClass& labeledClass() const { 00072 return ( *m_pointer ) ; 00073 } 00074 00075 conjugation::Label label() const { 00076 return ( m_label ) ; 00077 } 00078 00079 bool operator==( const conjugation::Label& aLabel ) const { 00080 return ( aLabel == m_label ) ; 00081 } 00082 00083 bool operator!=( const conjugation::Label& aLabel ) const { 00084 return ( aLabel != m_label ) ; 00085 } 00086 00087 00088 // static member functions 00089 00090 protected: 00091 // Constructors and destructor 00092 template<class THolder> 00093 LabeledCandidate( THolder aCandidateClass , 00094 const conjugation::Label aLabel ) : 00095 m_pointer(aCandidateClass), 00096 m_label(aLabel) {} 00097 00098 // protected member functions 00099 CandidateClass* pointer() { 00100 return m_pointer.pointer(); 00101 } 00102 00103 // protected const member functions 00104 const CandidateClass* pointer() const { 00105 return ( m_pointer.pointer() ) ; 00106 } 00107 00108 00109 private: 00110 // Constructors and destructor 00111 00112 // private member functions 00113 00114 // private const member functions 00115 00116 // data members 00117 ReferenceHolder<CandidateClass> m_pointer; 00118 conjugation::Label m_label ; 00119 00120 // static data members 00121 00122 } ; 00123 } 00124 00125 #endif /* DCHAIN_LABELEDCANDIDATE_H */