#include "lifecycle.hpp" namespace replay { Node::Node(int owner):owner_(owner) {} std::int64_t Node::initial_checksum(const Profile& profile) const { std::int64_t result=static_cast(profile.seed)*31; result+=static_cast(profile.rate)*7; result+=static_cast(profile.channels)*101; result+=static_cast(profile.recorder)*13; return result%65521; } void Node::rollback(DevicePort& port,std::vector& staged,int recorder) { if (recorder!=-1) port.close(owner_,recorder); for (auto it=staged.rbegin();it!=staged.rend();++it) port.close(owner_,*it); staged.clear(); } Callback Node::on_configure(DevicePort& port,const Profile& profile) { std::vector staged; int recorder=-1; port.begin_attempt(profile.fail_at); for (int channel=0;channel(index),value,data_.profile); } ++data_.samples; data_.total+=batch; std::int64_t residue=(data_.checksum*33+batch)%65521; if (residue<0) residue+=65521; data_.checksum=residue; if (data_.recorder!=-1) port.write(owner_,data_.recorder,batch); return Result::Ok; } NodeView Node::view() const { return data_; } }