CYCLUS
Public Types | Public Member Functions | List of all members
cyclus::toolkit::ResourceBuff Class Reference

Detailed Description

ResourceBuff is a helper function that provides semi-automated management of resource buffers (e.g.

agent stocks and inventories).

Methods that begin with a "set", "make", "push", or "pop" prefix change the state/behavior of the store; other methods do not. Default constructed resource store has infinite capacity. Resource popping occurs in the order the resources were pushed (i.e. oldest resources are popped first), unless explicitly specified otherwise.

In the near future this class will become deprecated in favor of ResBuf.

Definition at line 33 of file resource_buff.h.

#include <resource_buff.h>

Public Types

enum  AccessDir { FRONT, BACK }
 

Public Member Functions

double capacity () const
 
int count () const
 
bool empty () const
 
Resource::Ptr Pop (AccessDir dir=FRONT)
 
template<class T >
T::Ptr Pop ()
 
Manifest PopN (int num)
 
Manifest PopQty (double qty)
 
Manifest PopQty (double qty, double eps)
 
void Push (Resource::Ptr r)
 
template<class B >
void PushAll (std::vector< B > rs)
 
double quantity () const
 
 ResourceBuff ()
 
void set_capacity (double cap)
 
double space () const
 
virtual ~ResourceBuff ()
 

Member Enumeration Documentation

Enumerator
FRONT 
BACK 

Definition at line 35 of file resource_buff.h.

Constructor & Destructor Documentation

cyclus::toolkit::ResourceBuff::ResourceBuff ( )
inline

Definition at line 40 of file resource_buff.h.

virtual cyclus::toolkit::ResourceBuff::~ResourceBuff ( )
inlinevirtual

Definition at line 42 of file resource_buff.h.

Member Function Documentation

double cyclus::toolkit::ResourceBuff::capacity ( ) const
inline

Capacity returns the maximum resource quantity this store can hold (units based on constituent resource objects' units).

Never throws.

Definition at line 47 of file resource_buff.h.

int cyclus::toolkit::ResourceBuff::count ( ) const
inline

Count returns the total number of constituent resource objects in the store.

Never throws.

Definition at line 60 of file resource_buff.h.

bool cyclus::toolkit::ResourceBuff::empty ( ) const
inline

Returns true if there are no mats in mats_.

Definition at line 79 of file resource_buff.h.

Resource::Ptr cyclus::toolkit::ResourceBuff::Pop ( AccessDir  dir = FRONT)

Pop pops one resource object from the store.

Resources are not split. Resources are retrieved by default in the order they were pushed (i.e. oldest first).

Parameters
dirthe access direction, which is the front by default
Exceptions
ValueErrorthe store is empty.

Definition at line 95 of file resource_buff.cc.

template<class T >
T::Ptr cyclus::toolkit::ResourceBuff::Pop ( )
inline

A convenience method identical to Pop for auto-casting to specific Resource types.

Definition at line 120 of file resource_buff.h.

Manifest cyclus::toolkit::ResourceBuff::PopN ( int  num)

PopN pops the specified number or count of resource objects from the store.

Resources are not split. Resources are retrieved in the order they were pushed (i.e. oldest first).

Exceptions
ValueErrorthe specified pop number is larger than the store's current inventoryNum or the specified number is negative.

Definition at line 76 of file resource_buff.cc.

Manifest cyclus::toolkit::ResourceBuff::PopQty ( double  qty)

PopQty pops the specified quantity of resources from the buffer.

Resources are split if necessary in order to pop the exact quantity specified (within eps_rsrc()). Resources are retrieved in the order they were pushed (i.e. oldest first).

Exceptions
ValueErrorthe specified pop quantity is larger than the buffer's current quantity.

Definition at line 19 of file resource_buff.cc.

Manifest cyclus::toolkit::ResourceBuff::PopQty ( double  qty,
double  eps 
)

Same behavior as PopQty(double) except a non-zero eps may be specified for cases where qty might be larger than the buffer's current quantity.

Definition at line 53 of file resource_buff.cc.

void cyclus::toolkit::ResourceBuff::Push ( Resource::Ptr  r)

Push pushs a single resource object to the store.

Resource objects are never combined in the store; they are stored as unique objects. The resource object is only pushed to the store if it does not cause the store to exceed its capacity

Exceptions
ValueErrorthe pushing of the given resource object would cause the store to exceed its capacity.
KeyErrorthe resource object to be pushed is already present in the store.

Definition at line 114 of file resource_buff.cc.

template<class B >
void cyclus::toolkit::ResourceBuff::PushAll ( std::vector< B >  rs)
inline

PushAll pushess one or more resource objects (as a std::vector) to the store.

Resource objects are never combined in the store; they are stored as unique objects. The resource objects are only pushed to the store if they do not cause the store to exceed its capacity; otherwise none of the given resource objects are pushed to the store.

Exceptions
ValueErrorthe pushing of the given resource objects would cause the store to exceed its capacity.
KeyErrorone or more of the resource objects to be pushed are already present in the store.

Definition at line 150 of file resource_buff.h.

double cyclus::toolkit::ResourceBuff::quantity ( ) const
inline

Quantity returns the total resource quantity of constituent resource objects in the store.

Never throws.

Definition at line 66 of file resource_buff.h.

void cyclus::toolkit::ResourceBuff::set_capacity ( double  cap)

Set_capacity sets the maximum quantity this store can hold (units based on constituent resource objects' units).

Exceptions
ValueErrorthe new capacity is lower (by eps_rsrc()) than the quantity of resources that already exist in the store.

Definition at line 9 of file resource_buff.cc.

double cyclus::toolkit::ResourceBuff::space ( ) const
inline

Space returns the quantity of space remaining in this store.

It is effectively the difference between the capacity and the quantity and is never negative. Never throws.

Definition at line 74 of file resource_buff.h.


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