VISR  0.11.8
Versatile Interactive Scene Renderer
visr::rbbl::ObjectChannelAllocator Class Reference

#include <object_channel_allocator.hpp>

Public Member Functions

 ObjectChannelAllocator (std::size_t numChannels)
 
void setObjects (std::vector< objectmodel::ObjectId > const &objectIds)
 
std::size_t maxChannels () const
 
std::size_t numberUsedChannels () const
 
objectmodel::ObjectId getObjectForChannel (std::size_t channelId) const
 

Detailed Description

Class to manage the allocation of a limited number of rendering resources (channels) to a potentially larger number of objects where only a subset of these objects are of a type that uses these channels. The main rationale is that the allocated channel for an object does not change as long as the object exists. Objects are represented by arbitrary, unique objects ids, while channels are denoted by a consecutive set of integers (starting at zero)

Constructor & Destructor Documentation

visr::rbbl::ObjectChannelAllocator::ObjectChannelAllocator ( std::size_t  numChannels)
explicit

Constructor, constructs an allocator objects with no channels allocated.

Parameters
numChannelsThe number of rendering resources (channels)

Member Function Documentation

objectmodel::ObjectId visr::rbbl::ObjectChannelAllocator::getObjectForChannel ( std::size_t  channelId) const

Retrieve the channel index for a given object id.

Parameters
channelIdthe logical channel id.
Returns
The object id of the object to which this channel is allocated, or objectmodel::cInvalidObjectId if the channel is not allocated.
Exceptions
std::invalid_argumentIf channelId exceeds the number of rendering channels.
std::size_t visr::rbbl::ObjectChannelAllocator::maxChannels ( ) const
inline

Return the number of available rendering resources (channels) as set in the constructor.

std::size_t visr::rbbl::ObjectChannelAllocator::numberUsedChannels ( ) const

Return the number of currently allocated rendering resources (channels).

void visr::rbbl::ObjectChannelAllocator::setObjects ( std::vector< objectmodel::ObjectId > const &  objectIds)

Set the set of used object ids. This function internally recomputes the allocation of channels to objects, taking the previous object set into account to keep the allocation for already existing objects unchanged. Allocations for previously existing objects not present in the current object set are removed.

Parameters
objectIdsA vector containg the object ids of the current object set.
Exceptions
invalid_argumentIf the size of the object vector exceeds the maximum number of rendering resources (channels)

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