Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoBoardSynchronizer Class Reference

#include <GoBoardSynchronizer.h>

Inheritance diagram for GoBoardSynchronizer:

Inheritance graph
[legend]
List of all members.

Detailed Description

Synchronize two boards.

Definition at line 15 of file GoBoardSynchronizer.h.

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


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]

Definition at line 70 of file GoBoardSynchronizer.cpp.

References ExecuteSubscriber(), GoBoard::Init(), m_publisher, m_subscriber, GoBoard::Move(), GoBoard::MoveNumber(), OnBoardChange(), GoBoard::Setup(), and GoBoard::Size().

Referenced by UpdateSubscriber().

void GoBoardSynchronizer::UpdateIncremental (  )  [private]

Definition at line 79 of file GoBoardSynchronizer.cpp.

References ExecuteSubscriber(), FindNuCommon(), m_publisher, m_subscriber, GoBoard::Move(), GoBoard::MoveNumber(), OnUndo(), PreUndo(), SG_ASSERT, and GoBoard::Undo().

Referenced by UpdateSubscriber().

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::CmdSetupPlayer(), GoGtpEngine::RulesChanged(), GoAutoBookState::Synchronize(), and GoGame::UpdatePlayer().

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

const GoBoard& GoBoardSynchronizer::m_publisher [private]

Definition at line 71 of file GoBoardSynchronizer.h.

Referenced by FindNuCommon(), UpdateFromInit(), UpdateIncremental(), UpdateSubscriber(), and UpdateToPlay().

GoBoard* GoBoardSynchronizer::m_subscriber [private]

Definition at line 73 of file GoBoardSynchronizer.h.

Referenced by ExecuteSubscriber(), FindNuCommon(), SetSubscriber(), UpdateFromInit(), UpdateIncremental(), UpdateSubscriber(), and UpdateToPlay().


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


17 Jun 2010 Doxygen 1.4.7