Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgSearchStatistics.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgSearchStatistics.h
00003     Search statistics */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef SG_SEARCHSTATISTICS_H
00007 #define SG_SEARCHSTATISTICS_H
00008 
00009 #include <iosfwd>
00010 
00011 //----------------------------------------------------------------------------
00012 
00013 /** Statistics used in class SgSearch */
00014 class SgSearchStatistics
00015 {
00016 public:
00017     SgSearchStatistics();
00018 
00019     SgSearchStatistics(const SgSearchStatistics& stat);
00020 
00021     virtual ~SgSearchStatistics();
00022 
00023     SgSearchStatistics& operator=(const SgSearchStatistics& rhs);
00024 
00025     SgSearchStatistics& operator+=(const SgSearchStatistics& rhs);
00026 
00027     /** Set the number of nodes and leafs searched to zero. */
00028     void Clear();
00029 
00030     int DepthReached() const;
00031 
00032     virtual SgSearchStatistics* Duplicate() const;
00033 
00034     void IncNumEvals();
00035 
00036     void IncNumMoves();
00037 
00038     void IncNumNodes();
00039 
00040     void IncNumPassMoves();
00041 
00042     int NumEvals() const;
00043 
00044     int NumMoves() const;
00045 
00046     int NumNodes() const;
00047 
00048     double NumEvalsPerSecond() const;
00049 
00050     double NumNodesPerSecond() const;
00051 
00052     int NumPassMoves() const;
00053 
00054     void SetDepthReached(int depthReached);
00055 
00056     /** Set the time used to the given value.
00057         Only needed because doesn't keep track of real time used, and some
00058         searches might want to report the real time rather than the thread
00059         time. */
00060     void SetTimeUsed(double timeUsed);
00061 
00062     double TimeUsed() const;
00063 
00064 private:
00065     int m_numNodes;
00066     
00067     int m_numEvals;
00068     
00069     int m_numMoves;
00070     
00071     int m_numPass;
00072 
00073     int m_depthReached;
00074 
00075     double m_timeUsed;
00076 };
00077 
00078 std::ostream& operator<<(std::ostream& stream,
00079                          const SgSearchStatistics &w);
00080 
00081 inline int SgSearchStatistics::DepthReached() const
00082 {
00083     return m_depthReached;
00084 }
00085 
00086 inline void SgSearchStatistics::IncNumEvals()
00087 {
00088     ++m_numEvals;
00089 }
00090 
00091 inline void SgSearchStatistics::IncNumMoves()
00092 {
00093     ++m_numMoves;
00094 }
00095 
00096 inline void SgSearchStatistics::IncNumNodes()
00097 {
00098     ++m_numNodes;
00099 }
00100 
00101 inline void SgSearchStatistics::IncNumPassMoves()
00102 {
00103     ++m_numPass;
00104 }
00105 
00106 inline int SgSearchStatistics::NumEvals() const
00107 {
00108     return m_numEvals;
00109 }
00110 
00111 inline int SgSearchStatistics::NumMoves() const
00112 {
00113     return m_numMoves;
00114 }
00115 
00116 inline int SgSearchStatistics::NumNodes() const
00117 {
00118     return m_numNodes;
00119 }
00120 
00121 inline int SgSearchStatistics::NumPassMoves() const
00122 {
00123     return m_numPass;
00124 }
00125 
00126 inline void SgSearchStatistics::SetDepthReached(int depthReached)
00127 {
00128     m_depthReached = depthReached;
00129 }
00130 
00131 inline void SgSearchStatistics::SetTimeUsed(double timeUsed)
00132 {
00133     m_timeUsed = timeUsed;
00134 }
00135 
00136 inline double SgSearchStatistics::TimeUsed() const
00137 {
00138     return m_timeUsed;
00139 }
00140 
00141 //----------------------------------------------------------------------------
00142 
00143 #endif // SG_SEARCHSTATISTICS_H


Sun Mar 13 2011 Doxygen 1.7.1