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

GoBoardSynchronizer Class Reference

Synchronize two boards. More...

#include <GoBoardSynchronizer.h>

Inheritance diagram for GoBoardSynchronizer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GoBoardSynchronizer (const GoBoard &publisher)
 Create a synchronizer.
virtual ~GoBoardSynchronizer ()
void SetSubscriber (GoBoard &subscriber)
 Set the board that will subscribe to all the changes of the publisher.
void UpdateSubscriber ()
 Update the subscriber board.

Protected Member Functions

Hook functions for incremental update events

virtual void OnBoardChange ()
 Board was initialized with new size.
virtual void PrePlay (GoPlayerMove move)
 Move about to be executed.
virtual void OnPlay (GoPlayerMove move)
 Move was executed.
virtual void PreUndo ()
 Move about to be undone.
virtual void OnUndo ()
 Move was undone.

Private Member Functions

 GoBoardSynchronizer (const GoBoardSynchronizer &)
 Not implemented.
GoBoardSynchronizeroperator= (const GoBoardSynchronizer &)
 Not implemented.
void ExecuteSubscriber (const GoPlayerMove &move)
int FindNuCommon () const
void UpdateFromInit ()
void UpdateIncremental ()
void UpdateToPlay ()

Private Attributes

const GoBoardm_publisher
GoBoardm_subscriber

Detailed Description

Synchronize two boards.

Definition at line 15 of file GoBoardSynchronizer.h.


Constructor & Destructor Documentation

GoBoardSynchronizer::GoBoardSynchronizer ( const GoBoard publisher  ) 

Create a synchronizer.

The publisher board can be at any position; the subscriber match that position the first time BoardSynchronizer::UpdateSubscriber is called.

Definition at line 14 of file GoBoardSynchronizer.cpp.

GoBoardSynchronizer::~GoBoardSynchronizer (  )  [virtual]

Definition at line 20 of file GoBoardSynchronizer.cpp.

GoBoardSynchronizer::GoBoardSynchronizer ( const GoBoardSynchronizer  )  [private]

Not implemented.


Member Function Documentation

void GoBoardSynchronizer::ExecuteSubscriber ( const GoPlayerMove move  )  [private]

Definition at line 41 of file GoBoardSynchronizer.cpp.

References m_subscriber, OnPlay(), GoBoard::Play(), and PrePlay().

Referenced by UpdateFromInit(), and UpdateIncremental().

int GoBoardSynchronizer::FindNuCommon (  )  const [private]

Definition at line 30 of file GoBoardSynchronizer.cpp.

References m_publisher, m_subscriber, GoBoard::Move(), and GoBoard::MoveNumber().

Referenced by UpdateIncremental().

void GoBoardSynchronizer::OnBoardChange (  )  [protected, virtual]

Board was initialized with new size.

Default implementation does nothing.

Definition at line 48 of file GoBoardSynchronizer.cpp.

Referenced by UpdateFromInit().

void GoBoardSynchronizer::OnPlay ( GoPlayerMove  move  )  [protected, virtual]

Move was executed.

Default implementation does nothing.

Definition at line 57 of file GoBoardSynchronizer.cpp.

References SG_UNUSED().

Referenced by ExecuteSubscriber().

void GoBoardSynchronizer::OnUndo (  )  [protected, virtual]

Move was undone.

Default implementation does nothing.

Definition at line 66 of file GoBoardSynchronizer.cpp.

Referenced by UpdateIncremental().

GoBoardSynchronizer& GoBoardSynchronizer::operator= ( const GoBoardSynchronizer  )  [private]

Not implemented.

void GoBoardSynchronizer::PrePlay ( GoPlayerMove  move  )  [protected, virtual]

Move about to be executed.

Default implementation does nothing.

Definition at line 52 of file GoBoardSynchronizer.cpp.

References SG_UNUSED().

Referenced by ExecuteSubscriber().

void GoBoardSynchronizer::PreUndo (  )  [protected, virtual]

Move about to be undone.

Default implementation does nothing.

Definition at line 62 of file GoBoardSynchronizer.cpp.

Referenced by UpdateIncremental().

void GoBoardSynchronizer::SetSubscriber ( GoBoard subscriber  ) 

Set the board that will subscribe to all the changes of the publisher.

Can only be called once.

Definition at line 24 of file GoBoardSynchronizer.cpp.

References m_subscriber, and SG_ASSERT.

Referenced by GoAutoBookState::GoAutoBookState(), and GoPlayer::GoPlayer().

void GoBoardSynchronizer::UpdateFromInit (  )  [private]
void GoBoardSynchronizer::UpdateIncremental (  )  [private]
void GoBoardSynchronizer::UpdateSubscriber (  ) 

Update the subscriber board.

Calls Init, Play, Undo and/or SetToPlay to update the subscriber to the current state of the publisher. If no subscriber was set with SetSubscriber, this function does nothing.

Definition at line 96 of file GoBoardSynchronizer.cpp.

References GoBoard::GetHashCode(), m_publisher, m_subscriber, GoBoard::Rules(), GoBoard::Setup(), SG_ASSERT, GoBoard::Size(), UpdateFromInit(), UpdateIncremental(), and UpdateToPlay().

Referenced by GoGtpEngine::BoardChanged(), GoGtpEngine::RulesChanged(), GoGtpEngine::SetPlayer(), and GoAutoBookState::Synchronize().

void GoBoardSynchronizer::UpdateToPlay (  )  [private]

Definition at line 110 of file GoBoardSynchronizer.cpp.

References m_publisher, m_subscriber, GoBoard::SetToPlay(), and GoBoard::ToPlay().

Referenced by UpdateSubscriber().


Member Data Documentation


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


Sun Mar 13 2011 Doxygen 1.7.1