TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | List of all members
cherrypi::UpcStorage Class Reference

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< UpcIdsourceIds (UpcId id, Module *upTo=nullptr) const
 Recursively retrieve source UPC IDs up to a given module. More...
 
std::shared_ptr< UPCTupleupc (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
 

Detailed Description

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.

Constructor & Destructor Documentation

cherrypi::UpcStorage::UpcStorage ( )
cherrypi::UpcStorage::~UpcStorage ( )

Member Function Documentation

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.

std::vector<UpcPost> const& cherrypi::UpcStorage::getAllUpcs ( ) const
inline
UpcPost const * cherrypi::UpcStorage::post ( UpcId  id) const

Retrieve the full post data for a given ID.

void cherrypi::UpcStorage::setPersistent ( bool  persistent)

Controls whether UPCTuple and UpcPostData objects should be stored.

UpcId cherrypi::UpcStorage::sourceId ( UpcId  id) const

Retrieve the source UPC ID for the given UPC ID.

std::vector< UpcId > cherrypi::UpcStorage::sourceIds ( UpcId  id,
Module upTo = nullptr 
) const

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.

std::shared_ptr< UPCTuple > cherrypi::UpcStorage::upc ( UpcId  id) const

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().


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