5#include "sparta/serialization/checkpoint/CheckpointBase.hpp"
7namespace sparta::serialization::checkpoint
115 throw CheckpointError(
"Attempting to add a next checkpoint whose previous checkpoint pointer is not 'this'");
118 throw CheckpointError(
"Attempting to add a next checkpoint whose tick number (")
119 << next->
getTick() <<
" is less than this checkpoint's tick: " <<
getTick();
121 if(std::find(nexts_.begin(), nexts_.end(), next) != nexts_.end()){
122 throw CheckpointError(
"Next argument already present in this checkpoint's nexts_ list. Cannot re-add");
124 nexts_.push_back(next);
140 throw CheckpointError(
"Attempting to remove a next checkpoint whose previous pointer is not 'this'");
142 auto itr = std::find(nexts_.begin(), nexts_.end(), next);
143 if(itr == nexts_.end()){
144 throw CheckpointError(
"Next argument was not present in this checkpoint's nexts_ list. Cannot remove");
156 const std::vector<Checkpoint*>&
getNexts() const noexcept {
return nexts_; }
163 std::vector<chkpt_id_t> next_ids;
164 for (
const auto chkpt :
getNexts()) {
165 next_ids.push_back(chkpt->getID());
180 std::vector<Checkpoint*> nexts_;
Single checkpoint object interface with a tick number and an ID unique to the owning Checkpointer ins...
uint64_t chkpt_id_t
tick_t Checkpoint ID type to which checkpoints will refer
chkpt_id_t getID() const noexcept
Returns the ID of this checkpoint.
tick_t getTick() const noexcept
Returns the tick number at which this checkpoint was taken.
static const chkpt_id_t UNIDENTIFIED_CHECKPOINT
Indicates unidentified checkpoint (could mean 'invalid' or 'any') depending on context.
sparta::Scheduler::Tick tick_t
tick_t Tick type to which checkpoints will refer
Indicates that there was an issue operating on checkpoints within the SPARTA framework.
Single checkpoint object interface with a tick number and an ID unique to the owning Checkpointer ins...
Checkpoint()=delete
Not default constructable.
Checkpoint * getPrev() const noexcept
Returns the previous checkpoint. If this checkpoint is a snapshot, it has no previous checkpoint.
Checkpoint(const Checkpoint &)=delete
Not copy constructable.
const std::vector< Checkpoint * > & getNexts() const noexcept
Returns next checkpoint following *this. May be an empty vector if there are no later checkpoints fol...
Checkpoint & operator=(Checkpoint &&)=delete
Not move assignable.
Checkpoint(Checkpoint &&)=delete
Not move constructable.
Checkpoint & operator=(const Checkpoint &)=delete
Non-assignable.
std::vector< chkpt_id_t > getNextIDs() const override
Returns next checkpoint following *this. May be an empty vector if there are no later checkpoints.
void addNext(Checkpoint *next)
Adds another next checkpoint following *this.
chkpt_id_t getPrevID() const override
Get the ID of our previous checkpoint. Returns UNIDENTIFIED_CHECKPOINT only for the head checkpoint.
void setPrev(Checkpoint *prev) noexcept
Sets the previous checkpoint of this checkpoint to prev.
Checkpoint(chkpt_id_t id, tick_t tick, Checkpoint *prev)
void removeNext(Checkpoint *next)
Removes a checkpoint following *this because it was deleted.
virtual ~Checkpoint()
Removes this checkpoint from the chain and patches chain between prev and each item in the nexts list...