Class base_cache

Nested Relationships

Nested Types

Inheritance Relationships

Base Types

Derived Type

Class Documentation

class base_cache : public cosm::repr::unicell_immovable_entity2D, public rer::client<base_cache>, public cosm::repr::colored_entity, public rpprototype::clonable<base_cache>

Base class for representating a cache within the arena. Caches do not have state, and if/when a cache becomes empty, it needs to be deleted by an enclosing class. Caches have both real (where they actually live in the world) and discretized locations (where they are mapped to within the arena map).

Subclassed by cosm::arena::repr::arena_cache

Public Functions

explicit base_cache(const params &p)
~base_cache(void) override = default
void block_add(crepr::sim_block3D *block)

Add a new block to the cache’s list of blocks.

Does not update the block’s location.

void block_remove(const crepr::sim_block3D *victim)

Remove a block from the cache’s list of blocks, without modifying it.

crepr::sim_block3D *block_select(rmath::rng *rng)

Get a random block from the cache.

inline cds::block3D_vectorno &blocks(void)

Get a list of the blocks currently in the cache.

inline const cds::block3D_vectorno &blocks(void) const
void blocks_map_enable(void)
std::unique_ptr<base_cache> clone(void) const final override
bool contains_block(const crepr::sim_block3D *c_block) const
inline void creation_ts(const rtypes::timestep &ts)
inline rtypes::timestep creation_ts(void) const
inline bool dloccmp(base_cache &other)

Compare two base_cache objects for equality based on their discrete center.

inline bool idcmp(const base_cache &other) const

Compare two base_cache objects for equality based on their ID.

inline size_t n_blocks(void) const
bool operator==(const base_cache &other) const = delete

Disallow direct object comparisons, because we may want to compare for equality in terms of IDs or object locations, and it is better to require explicit comparisons for BOTH, rather than just one. It also makes it unecessary to have to remember which type the comparison operator==() does for this class.

Public Static Attributes

static constexpr const size_t kMinBlocks = 2

The minimum # of blocks required for a cache to exist (less than this and you just have a bunch of blocks).

struct params
Param dimension:

The size of the cache. Does not have to be a multiple of the arena resolution, but doing so makes it easier.

Param resolution:

The arena resolution.

Param center:

(X,Y) coordinates of the center of the cache.

Param blocks:

The initial block list for the cache.

Param id:

The ID to assign to the cache; -1 for a new cache, which will generate a new ID, or any positive # to use the same ID as an existing cache (used when cloning a cache into a robot’s perception).

Public Members

const cds::block3D_vectorno &&blocks
rmath::vector2d center
rspatial::euclidean_dist dimension
rtypes::type_uuid id
rtypes::discretize_ratio resolution