Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoKomi Class Reference

#include <GoKomi.h>

List of all members.


Detailed Description

Class wrapping a komi value.

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

Definition at line 16 of file GoKomi.h.

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.

Classes

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


Constructor & Destructor Documentation

GoKomi::GoKomi (  ) 

Construct komi with unknown value.

Definition at line 87 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 93 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 40 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 117 of file GoKomi.h.

References m_isUnknown.

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

Definition at line 112 of file GoKomi.h.

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

Definition at line 100 of file GoKomi.h.

References m_isUnknown, and m_value.

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

Definition at line 107 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 122 of file GoKomi.h.

References m_isUnknown, and m_value.

Referenced by GoGtpEngine::CmdFinalScore(), and GoBoardUtil::PassWins().

string GoKomi::ToString (  )  const

Convert komi to string.

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

Definition at line 63 of file GoKomi.cpp.

References m_isUnknown, and m_value.

Referenced by operator<<().


Member Data Documentation

bool GoKomi::m_isUnknown [private]

Definition at line 73 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 78 of file GoKomi.h.

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


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


17 Jun 2010 Doxygen 1.4.7