UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
Loading...
Searching...
No Matches
UCILoader::EngineOptionsMap Class Reference

Container and iterator for engine option proxies. More...

#include <EngineConnection.h>

Inheritance diagram for UCILoader::EngineOptionsMap:
UCILoader::IOptionConsumer

Public Types

using map_iterator = Map::iterator
 

Public Member Functions

 EngineOptionsMap (const std::shared_ptr< AbstractPipeWriter > &writer)
 
EngineOptionProxyget (const std::string &id)
 
const EngineOptionProxyget (const std::string &id) const
 
bool contains (const std::string &id) const
 Check if the engine has an option with the specified name.
 
iterator begin ()
 Get iterator to the first option.
 
iterator end ()
 Get iterator to one past the last option.
 
EngineOptionProxyoperator[] (const std::string &id)
 Access option by name using bracket notation.
 
const EngineOptionProxyoperator[] (const std::string &id) const
 Access option by name using bracket notation (const version).
 

Detailed Description

Container and iterator for engine option proxies.

EngineOptionsMap acts as a map-like container populated from engine's option responses during UCI initialization. Access options by name using the [] operator or iterate over all options using begin() and end().

Options are populated automatically as the engine sends its option declarations. It's recommended to call sync() on the EngineInstance to ensure all options are loaded before accessing this map. It's recommended to call sync() before querying options to ensure completeness.

Usage:

auto instance = builder.build(engine, Loggers::toStd() | LoggerTraits::Pretty);
instance->sync(); // Ensure all options are loaded
if (instance->options.contains("Hash")) {
instance->options["Hash"] = 256;
}
for (auto& option : instance->options) {
std::cout << option.id() << std::endl;
}
const LoggerTrait & Pretty
Trait that formats log messages for human readability.
Definition: Logger.cpp:165
LoggerBuilder toStd()
Create a logger that outputs to standard output.
Definition: Logger.cpp:176
See also
EngineInstance::sync() for populating options

Member Function Documentation

◆ begin()

iterator UCILoader::EngineOptionsMap::begin ( )
inline

Get iterator to the first option.

Returns
Iterator pointing to the first EngineOptionProxy

◆ contains()

bool UCILoader::EngineOptionsMap::contains ( const std::string &  id) const
inline

Check if the engine has an option with the specified name.

Parameters
idThe option identifier to check
Returns
True if the option exists, false otherwise

◆ end()

iterator UCILoader::EngineOptionsMap::end ( )
inline

Get iterator to one past the last option.

Returns
Iterator pointing past the last EngineOptionProxy

◆ operator[]() [1/2]

EngineOptionProxy & UCILoader::EngineOptionsMap::operator[] ( const std::string &  id)
inline

Access option by name using bracket notation.

Parameters
idThe option identifier
Returns
Reference to the EngineOptionProxy for the specified option
Exceptions
std::out_of_rangeif the option doesn't exist

◆ operator[]() [2/2]

const EngineOptionProxy & UCILoader::EngineOptionsMap::operator[] ( const std::string &  id) const
inline

Access option by name using bracket notation (const version).

Parameters
idThe option identifier
Returns
Const reference to the EngineOptionProxy for the specified option
Exceptions
std::out_of_rangeif the option doesn't exist

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