TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Stores a graph of UPC communication, including any transactional data. More...
#include <upcstorage.h>
Public Member Functions | |
UpcStorage () | |
~UpcStorage () | |
void | setPersistent (bool persistent) |
Controls whether UPCTuple and UpcPostData objects should be stored. More... | |
UpcId | addUpc (FrameNum frame, UpcId sourceId, Module *source, std::shared_ptr< UPCTuple > upc, std::shared_ptr< UpcPostData > data=nullptr) |
Adds a UPC tuple with accompanying transaction data. More... | |
UpcId | sourceId (UpcId id) const |
Retrieve the source UPC ID for the given UPC ID. More... | |
std::vector< UpcId > | sourceIds (UpcId id, Module *upTo=nullptr) const |
Recursively retrieve source UPC IDs up to a given module. More... | |
std::shared_ptr< UPCTuple > | upc (UpcId id) const |
Retrieve the UPC Tuple for a given ID. More... | |
UpcPost const * | post (UpcId id) const |
Retrieve the full post data for a given ID. More... | |
std::vector< UpcPost const * > | upcPostsFrom (Module *module, FrameNum frame=-1) const |
Retrieve all posts from a given module. More... | |
std::vector< UpcPost > const & | getAllUpcs () const |
Stores a graph of UPC communication, including any transactional data.
The storage will retain any UPCTuple and accompanying UpcPostData objects added via addUpc(). It is possible to disable permanent storage of tuples and data objects via setPersistent(), which is useful for evaluation settings in which memory is scarce.
cherrypi::UpcStorage::UpcStorage | ( | ) |
cherrypi::UpcStorage::~UpcStorage | ( | ) |
UpcId cherrypi::UpcStorage::addUpc | ( | FrameNum | frame, |
UpcId | sourceId, | ||
Module * | source, | ||
std::shared_ptr< UPCTuple > | upc, | ||
std::shared_ptr< UpcPostData > | data = nullptr |
||
) |
Adds a UPC tuple with accompanying transaction data.
The returned ID can be used to refer to this UPC in the future.
|
inline |
Retrieve the full post data for a given ID.
void cherrypi::UpcStorage::setPersistent | ( | bool | persistent | ) |
Controls whether UPCTuple and UpcPostData objects should be stored.
Retrieve the source UPC ID for the given UPC ID.
Recursively retrieve source UPC IDs up to a given module.
If upTo is nullptr, retrieve all source UPC IDs up to and including the root UPC.
Retrieve the UPC Tuple for a given ID.
If the storage is not persistent, this function will return nullptr.
std::vector< UpcPost const * > cherrypi::UpcStorage::upcPostsFrom | ( | Module * | module, |
FrameNum | frame = -1 |
||
) | const |
Retrieve all posts from a given module.
Optionally, this can be restricted to a given frame number. Note that these pointers might be invalidated in subsequent calls to addUpc().