libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
LibSgfcPlusPlus::SgfcSaveStream Class Reference

The SgfcSaveStream class captures the stream of save data that is generated by SGF. More...

#include <SgfcSaveStream.h>

Public Member Functions

 SgfcSaveStream ()
 Initializes a newly constructed SgfcSaveStream object. The object clears all data captured from previous save operations.
 
virtual ~SgfcSaveStream ()
 Destroys and cleans up the SgfcSaveStream object.
 
std::vector< std::shared_ptr< SgfcSgfContent > > GetSgfContents () const
 Returns a collection of save data captured so far by the SgfcSaveStream object. The save data objects appear in the collection in the order in which they are generated by SGFC. The collection is empty if SGFC has not generated any save data.
 

Static Public Member Functions

static SaveFileHandler * CreateSaveFileHandler ()
 Returns a newly allocated SaveFileHandler structure that can be passed to the SGFC global function SaveSGF(). The structure is good only for a single invocation of SaveSGF() because SaveSGF() frees the memory allocated for the SaveFileHandler structure. If the caller does not invoke SaveSGF() it becomes responsible for freeing the SaveFileHandler structure.
 

Detailed Description

The SgfcSaveStream class captures the stream of save data that is generated by SGF.

The capturing process does not depend on a particular instance of SgfcSaveStream. It is based on global/static functions and variables that are hidden behind the facade of SgfcSaveStream. However, an instance of SgfcSaveStream is required to access the captured data.

An actor that wants to perform an SGFC save operation invokes the static function CreateSaveFileHandler(). This returns a structure that the actor can then pass to the SGFC global function SaveSGF() to start the save operation. SaveSGF() will free the memory allocated for the structure, so it is good only for a single save operation.

Before the actor starts the save operation, though, it must construct an SgfcSaveStream object. Upon construction this clears all data captured from previous save operations.

While SaveSGF() runs it invokes various callback functions, pointers to which were stored in the structure created by CreateSaveFileHandler. The callback functions are internals of SgfcSaveStream that handle the capturing process.

After the save operation has finished the actor can access the captured save data by invoking the GetSgfContents() method. When SgfcSaveStream is destroyed the actor no longer has access to the captured data.

Only one SgfcSaveStream can be active at any given time.

An SgfcSaveStream object that is left alive can capture the results of multiple save operations. GetSgfContents() returns all save data that was captured during the entire lifetime of the SgfcSaveStream object.

Constructor & Destructor Documentation

◆ SgfcSaveStream()

LibSgfcPlusPlus::SgfcSaveStream::SgfcSaveStream ( )

Initializes a newly constructed SgfcSaveStream object. The object clears all data captured from previous save operations.

Exceptions
std::logic_errorIs thrown if another SgfcSaveStream object already exists.

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