1 #ifndef CYCLUS_SRC_RESOURCE_H_ 2 #define CYCLUS_SRC_RESOURCE_H_ 6 #include <boost/shared_ptr.hpp> 21 friend class ::SimInitTest;
24 typedef boost::shared_ptr<Resource>
Ptr;
26 Resource() : state_id_(nextstate_id_++), obj_id_(nextobj_id_++) {}
33 const int obj_id()
const {
return obj_id_; }
53 virtual int qual_id()
const = 0;
56 virtual const ResourceType
type()
const = 0;
60 virtual Ptr
Clone()
const = 0;
83 static int nextstate_id_;
84 static int nextobj_id_;
91 std::vector<typename T::Ptr>
ResCast(std::vector<Resource::Ptr> rs) {
92 std::vector<typename T::Ptr> casted;
93 for (
int i = 0; i < rs.size(); ++i) {
94 casted.push_back(boost::dynamic_pointer_cast<T>(rs[i]));
102 return boost::dynamic_pointer_cast<T>(r);
107 #endif // CYCLUS_SRC_RESOURCE_H_
const int obj_id() const
Returns the unique id corresponding to this resource object.
virtual const ResourceType type() const =0
A unique type/name for the concrete resource implementation.
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
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.
virtual int qual_id() const =0
Returns an id representing the specific resource implementation's internal state that is not accessib...
virtual double quantity() const =0
Returns the quantity of this resource with dimensions as specified by the return value of units()...
virtual std::string units() const =0
Returns the units this resource is based in (e.g. "kg").
Resource defines an abstract interface implemented by types that are offered, requested, and transferred between simulation agents.
void BumpStateId()
Assigns a new, unique internal id to this resource and its state.
virtual Ptr Clone() const =0
Returns an untracked (not part of the simulation) copy of the resource.
A simulation context provides access to necessary simulation-global functions and state...
boost::shared_ptr< Resource > Ptr
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
virtual Ptr ExtractRes(double quantity)=0
Splits the resource and returns the extracted portion as a new resource object.
Handles initialization of a simulation from the output database.
virtual void Record(Context *ctx) const =0
Records the resource's state to the output database.