Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Classes | Public Member Functions | Private Attributes

GoKomi Class Reference

Class wrapping a komi value. More...

#include <GoKomi.h>

List of all members.

Classes

class  InvalidKomi
 Exception thrown if komi is constructed with invalid value. More...

Public Member Functions

 GoKomi ()
 Construct komi with unknown value.
 GoKomi (float komi)
 Construct komi from float.
 GoKomi (const std::string &komi)
 Construct komi from string.
GoKomioperator= (const GoKomi &komi)
bool operator== (const GoKomi &komi) const
bool operator!= (const GoKomi &komi) const
bool IsUnknown () const
 Check if komi is unknown.
float ToFloat () const
 Convert komi to float.
std::string ToString () const
 Convert komi to string.

Private Attributes

bool m_isUnknown
int m_value
 Komi value stored as integer.

Detailed Description

Class wrapping a komi value.

Supported komi values are "unknown" or multiples of 0.5.

Definition at line 15 of file GoKomi.h.


Constructor & Destructor Documentation

GoKomi::GoKomi (  ) 

Construct komi with unknown value.

Definition at line 78 of file GoKomi.h.

Referenced by GoKomi().

GoKomi::GoKomi ( float  komi  ) 

Construct komi from float.

Parameters:
komi The komi, will be rounded to a multiple of 0.5.

Definition at line 84 of file GoKomi.h.

GoKomi::GoKomi ( const std::string &  komi  ) 

Construct komi from string.

Parameters:
komi The string, leading and trailing whitespaces will be ignored, empty for unknown komi, float otherwise. The float will be rounded to a multiple of 0.5.
Exceptions:
InvalidKomi If string is not empty or contains a float.

Definition at line 39 of file GoKomi.cpp.

References GoKomi(), m_isUnknown, and m_value.


Member Function Documentation

bool GoKomi::IsUnknown (  )  const

Check if komi is unknown.

Returns:
true, if komi has unknown value.

Definition at line 108 of file GoKomi.h.

References m_isUnknown.

Referenced by GoGame::Init(), and GoGame::SetKomiGlobal().

bool GoKomi::operator!= ( const GoKomi komi  )  const

Definition at line 103 of file GoKomi.h.

GoKomi & GoKomi::operator= ( const GoKomi komi  ) 

Definition at line 91 of file GoKomi.h.

References m_isUnknown, and m_value.

bool GoKomi::operator== ( const GoKomi komi  )  const

Definition at line 98 of file GoKomi.h.

References m_isUnknown, and m_value.

float GoKomi::ToFloat (  )  const

Convert komi to float.

Returns:
The komi value as a float, zero if komi is unknown.

Definition at line 113 of file GoKomi.h.

References m_isUnknown, and m_value.

Referenced by GoGtpEngine::CmdFinalScore(), GoSafetyUtil::GetWinner(), GoGame::Init(), GoBoardUtil::ScorePosition(), GoGame::SetKomiGlobal(), and GoBoardUtil::TrompTaylorPassWins().

string GoKomi::ToString (  )  const

Convert komi to string.

Returns:
The komi value as a string, empty string if komi is unknown.

Definition at line 62 of file GoKomi.cpp.

References m_isUnknown, and m_value.

Referenced by operator<<().


Member Data Documentation

bool GoKomi::m_isUnknown [private]

Definition at line 65 of file GoKomi.h.

Referenced by GoKomi(), IsUnknown(), operator=(), operator==(), ToFloat(), and ToString().

int GoKomi::m_value [private]

Komi value stored as integer.

Corresponds to the real komi multiplied by two.

Definition at line 69 of file GoKomi.h.

Referenced by GoKomi(), operator=(), operator==(), ToFloat(), and ToString().


The documentation for this class was generated from the following files:


Sun Mar 13 2011 Doxygen 1.7.1