-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCheckpoint.hpp
82 lines (61 loc) · 1.44 KB
/
Checkpoint.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Checkpoint.hpp
// NSGA-Parallel-Backend
//
// Created by a1091793 on 25/11/2015.
//
//
#ifndef Checkpoint_h
#define Checkpoint_h
#include <boost/foreach.hpp>
#include <boost/serialization/assume_abstract.hpp>
#include <boost/shared_ptr.hpp>
#include "Population.hpp"
class CheckpointBase
{
public:
virtual bool operator() (PopulationSPtr population) = 0;
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT( CheckpointBase )
typedef boost::shared_ptr<CheckpointBase> CheckpointBaseSPtr;
class DummyCheckpoint : public CheckpointBase
{
public:
bool
operator()(PopulationSPtr population)
{
return true;
}
};
class Checkpoints
{
private:
std::vector<CheckpointBaseSPtr> my_checkpoints;
// std::vector<CheckpointBase &> my_checkpoints;
public:
Checkpoints()
{
}
void
addCheckpoint(CheckpointBaseSPtr checkpoint_2_add)
{
my_checkpoints.push_back(checkpoint_2_add);
}
bool
operator()(PopulationSPtr population)
{
bool do_continue = true;
BOOST_FOREACH(CheckpointBaseSPtr chckpnt, my_checkpoints)
{
do_continue = (do_continue && chckpnt->operator ()(population));
}
return (do_continue);
}
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(my_checkpoints);
}
};
#endif /* Checkpoint_h */