1#ifndef CYCLUS_SRC_RESOURCE_H_
2#define CYCLUS_SRC_RESOURCE_H_
6#include <boost/shared_ptr.hpp>
24 friend class ::SimInitTest;
27 typedef boost::shared_ptr<Resource>
Ptr;
29 Resource() : state_id_(nextstate_id_++), obj_id_(nextobj_id_++) {}
36 const int obj_id()
const {
return obj_id_; }
72 virtual std::string
units()
const = 0;
110 static int nextstate_id_;
111 static int nextobj_id_;
124std::vector<typename T::Ptr>
ResCast(std::vector<Resource::Ptr>
rs) {
125 std::vector<typename T::Ptr>
casted;
126 for (
int i = 0; i <
rs.size(); ++i) {
127 casted.push_back(boost::dynamic_pointer_cast<T>(
rs[i]));
135 return boost::dynamic_pointer_cast<T>(
r);
141 std::vector<typename T::Ptr>
ts_pkgd;
149 for (
int i = 0; i <
packages.size(); ++i) {
a holding class for information related to a TradeExecutor
A simulation context provides access to necessary simulation-global functions and state.
A generic mechanism to manually manage exceptions.
boost::shared_ptr< Package > Ptr
static std::string unpackaged_name()
Resource defines an abstract interface implemented by types that are offered, requested,...
virtual Ptr PackageExtract(double qty, std::string new_package_name)=0
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
virtual Ptr ExtractRes(double quantity)=0
Splits the resource and returns the extracted portion as a new resource object.
virtual const ResourceType type() const =0
A unique type/name for the concrete resource implementation.
virtual Ptr Clone() const =0
Returns an untracked (not part of the simulation) copy of the resource.
virtual std::string units() const =0
Returns the units this resource is based in (e.g. "kg").
boost::shared_ptr< Resource > Ptr
virtual void Absorb(Ptr res)
To enable the Absorb method to be called on any child resource, define a null op Absorb method here.
virtual void Record(Context *ctx) const =0
Records the resource's state to the output database.
virtual double quantity() const =0
Returns the quantity of this resource with dimensions as specified by the return value of units().
virtual void ChangePackage(std::string new_package_name=Package::unpackaged_name())
Changes the product's package id.
const int obj_id() const
Returns the unique id corresponding to this resource object.
virtual std::string package_name()
Returns the package id.
void BumpStateId()
Assigns a new, unique internal id to this resource and its state.
virtual int qual_id() const =0
Returns an id representing the specific resource implementation's internal state that is not accessib...
virtual void Decay(int curr_time)
To enable the Decay method to be called on any child resource, define a null op Decay method here.
std::vector< typename T::Ptr > Package(Package::Ptr pkg)
Repackages a single resource into a package.
Handles initialization of a simulation from the output database.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
std::vector< typename T::Ptr > ResCast(std::vector< Resource::Ptr > rs)
Casts a vector of Resources into a vector of a specific resource type T.
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters