CMS 3D CMS Logo

edm::Hash< I > Class Template Reference

#include <DataFormats/Provenance/interface/Hash.h>

List of all members.

Public Types

typedef std::string value_type

Public Member Functions

value_type compactForm () const
 Hash (Hash< I > const &)
 Hash (value_type const &v)
 Hash ()
bool isCompactForm () const
bool isValid () const
bool operator!= (Hash< I > const &other) const
bool operator< (Hash< I > const &other) const
Hash< I > const & operator= (Hash< I > const &iRHS)
bool operator== (Hash< I > const &other) const
bool operator> (Hash< I > const &other) const
std::ostream & print (std::ostream &os) const
void swap (Hash< I > &other)

Private Member Functions

template<typename Op>
bool compareUsing (Hash< I > const &iOther, Op op) const
void fixup ()
void throwIfIllFormed () const
 Hexified version of data *must* contain a multiple of 2 bytes.

Private Attributes

value_type hash_


Detailed Description

template<int I>
class edm::Hash< I >

Definition at line 32 of file Hash.h.


Member Typedef Documentation

template<int I>
typedef std::string edm::Hash< I >::value_type

Definition at line 34 of file Hash.h.


Constructor & Destructor Documentation

template<int I>
edm::Hash< I >::Hash (  )  [inline]

Definition at line 95 of file Hash.h.

References edm::Hash< I >::fixup().

00095                 : 
00096     hash_() 
00097   {
00098     fixup();
00099   }

template<int I>
edm::Hash< I >::Hash ( value_type const &  v  )  [explicit]

template<int I>
edm::Hash< I >::Hash ( Hash< I > const &  iOther  )  [inline]

Definition at line 111 of file Hash.h.

References edm::Hash< I >::fixup().

00111                                     :
00112     hash_(iOther.hash_)
00113   {
00114       fixup();
00115   }


Member Function Documentation

template<int I>
Hash< I >::value_type edm::Hash< I >::compactForm (  )  const [inline]

Definition at line 192 of file Hash.h.

References edm::Hash< I >::compactForm(), and edm::Hash< I >::hash_.

Referenced by edm::Hash< I >::compactForm(), and edm::StreamerOutputModuleBase::serializeRegistry().

00193   {
00194     if (this->isCompactForm()) {
00195       return hash_;
00196     }
00197     Hash<I> tMe(*this);
00198     return tMe.compactForm();
00199   }

template<int I>
template<typename Op>
bool edm::Hash< I >::compareUsing ( Hash< I > const &  iOther,
Op  op 
) const [inline, private]

Definition at line 74 of file Hash.h.

References edm::Hash< I >::hash_, and edm::Hash< I >::isCompactForm().

Referenced by edm::Hash< I >::operator!=(), edm::Hash< I >::operator<(), edm::Hash< I >::operator==(), and edm::Hash< I >::operator>().

00074                                                        {
00075         if(this->isCompactForm() == iOther.isCompactForm()) {
00076           return op(this->hash_,iOther.hash_);
00077         }
00078         Hash<I> tMe(*this);
00079         Hash<I> tOther(iOther);
00080         return op(tMe.hash_,tOther.hash_);
00081       }

template<int I>
void edm::Hash< I >::fixup (  )  [inline, private]

Definition at line 220 of file Hash.h.

References cms::MD5Result::compactForm(), cms::MD5Result::fromHexifiedString(), edm::Hash< I >::hash_, edm::detail::InvalidHash(), edm::errors::LogicError, and pyDBSRunClass::temp.

Referenced by edm::Hash< I >::Hash(), edm::Hash< I >::operator=(), and edm::Hash< I >::swap().

00220                  {
00221     switch (hash_.size()) {
00222       case 0:
00223       {
00224         hash_ = edm::detail::InvalidHash();
00225       } 
00226       case 16: 
00227       {
00228         break;
00229       }
00230       case 32:
00231       {
00232         cms::MD5Result temp;
00233         temp.fromHexifiedString(hash_);
00234         hash_ = temp.compactForm();
00235         break;
00236       }
00237       default:
00238       {
00239         throw edm::Exception(edm::errors::LogicError)
00240           << "edm::Hash<> instance with data in illegal state:\n"
00241           << hash_
00242           << "\nPlease report this to the core framework developers";
00243       }
00244     }
00245   }

template<int I>
bool edm::Hash< I >::isCompactForm (  )  const [inline]

Definition at line 249 of file Hash.h.

References edm::Hash< I >::hash_.

Referenced by edm::Hash< I >::compareUsing(), and edm::Hash< I >::isValid().

00249                                     {
00250     return 16 == hash_.size();
00251   }

template<int I>
bool edm::Hash< I >::isValid ( void   )  const [inline]

Definition at line 130 of file Hash.h.

References edm::Hash< I >::hash_, edm::detail::InvalidHash(), and edm::Hash< I >::isCompactForm().

Referenced by edm::ParameterSet::id(), edm::Principal::Principal(), and edm::BranchDescription::throwIfInvalid_().

00131   {
00132     return isCompactForm() ? (hash_ != edm::detail::InvalidHash()) : (hash_.size()!=0);
00133   }

template<int I>
bool edm::Hash< I >::operator!= ( Hash< I > const &  other  )  const [inline]

Definition at line 162 of file Hash.h.

References edm::Hash< I >::compareUsing().

00163   {
00164     return this->compareUsing(other, std::not_equal_to<std::string >());
00165   }

template<int I>
bool edm::Hash< I >::operator< ( Hash< I > const &  other  )  const [inline]

Definition at line 138 of file Hash.h.

References edm::Hash< I >::compareUsing().

00139   {
00140     return this->compareUsing(other, std::less<std::string >());
00141   }

template<int I>
Hash< I > const & edm::Hash< I >::operator= ( Hash< I > const &  iRHS  )  [inline]

Definition at line 120 of file Hash.h.

References edm::Hash< I >::fixup(), and edm::Hash< I >::hash_.

00121   {
00122     hash_=iRHS.hash_;
00123     fixup();
00124     return *this;
00125   }

template<int I>
bool edm::Hash< I >::operator== ( Hash< I > const &  other  )  const [inline]

Definition at line 154 of file Hash.h.

References edm::Hash< I >::compareUsing().

00155   {
00156     return this->compareUsing(other, std::equal_to<std::string >());
00157   }

template<int I>
bool edm::Hash< I >::operator> ( Hash< I > const &  other  )  const [inline]

Definition at line 146 of file Hash.h.

References edm::Hash< I >::compareUsing().

00147   {
00148     return this->compareUsing(other, std::greater<std::string >());
00149   }

template<int I>
std::ostream & edm::Hash< I >::print ( std::ostream &  os  )  const [inline]

Definition at line 170 of file Hash.h.

References cms::MD5Result::bytes, edm::copy_all(), edm::Hash< I >::hash_, pyDBSRunClass::temp, and cms::MD5Result::toString().

00171   {
00172     Hash<I> tMe(*this);
00173     cms::MD5Result temp;
00174     copy_all(tMe.hash_, temp.bytes);
00175     os << temp.toString();
00176     return os;
00177   }

template<int I>
void edm::Hash< I >::swap ( Hash< I > &  other  )  [inline]

Definition at line 182 of file Hash.h.

References edm::Hash< I >::fixup(), and edm::Hash< I >::hash_.

Referenced by edm::ProcessHistory::id(), edm::swap(), edm::TriggerResults::swap(), and edm::ProcessHistory::swap().

00183   {
00184     fixup();
00185     hash_.swap(other.hash_);
00186     fixup();
00187   }

template<int I>
void edm::Hash< I >::throwIfIllFormed (  )  const [inline, private]

Hexified version of data *must* contain a multiple of 2 bytes.

If it does not, throw an exception.

Definition at line 204 of file Hash.h.

References edm::Hash< I >::hash_, and edm::errors::LogicError.

00205   {
00206     // Fixup not needed here.
00207     if (hash_.size() % 2 == 1)
00208       {
00209         throw edm::Exception(edm::errors::LogicError)
00210           << "Ill-formed Hash instance. "
00211           << "Please report this to the core framework developers";
00212       }
00213   }


Member Data Documentation

template<int I>
value_type edm::Hash< I >::hash_ [private]

Definition at line 83 of file Hash.h.

Referenced by edm::Hash< I >::compactForm(), edm::Hash< I >::compareUsing(), edm::Hash< I >::fixup(), edm::Hash< I >::isCompactForm(), edm::Hash< I >::isValid(), edm::Hash< I >::operator=(), edm::Hash< I >::print(), edm::Hash< I >::swap(), and edm::Hash< I >::throwIfIllFormed().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:41:13 2009 for CMSSW by  doxygen 1.5.4