Merge pull request #982 from dr-robertk/PR/copyable-simulator-timer

Allow SimulatorTimers to be copied.
This commit is contained in:
Atgeirr Flø Rasmussen 2016-03-29 11:09:14 +02:00
commit 7a5e8865b5
5 changed files with 28 additions and 0 deletions

View File

@ -153,4 +153,13 @@ namespace Opm
return start_date_time_;
}
/// return copy of object
std::unique_ptr< SimulatorTimerInterface >
AdaptiveSimulatorTimer::clone() const
{
return std::unique_ptr< SimulatorTimerInterface > (new AdaptiveSimulatorTimer( *this ));
}
} // namespace Opm

View File

@ -93,6 +93,9 @@ namespace Opm
/// \brief start date time of simulation
boost::posix_time::ptime startDateTime() const;
/// return copy of object
virtual std::unique_ptr< SimulatorTimerInterface > clone() const;
protected:
const boost::posix_time::ptime start_date_time_;
const double start_time_;

View File

@ -148,5 +148,13 @@ namespace Opm
return int(timesteps_.size()) == current_step_;
}
/// return copy of object
std::unique_ptr< SimulatorTimerInterface >
SimulatorTimer::clone() const
{
return std::unique_ptr< SimulatorTimerInterface > (new SimulatorTimer( *this ));
}
} // namespace Opm

View File

@ -104,6 +104,9 @@ namespace Opm
/// Return true if op++() has been called numSteps() times.
bool done() const;
/// return copy of object
virtual std::unique_ptr< SimulatorTimerInterface > clone() const;
private:
std::vector<double> timesteps_;
int current_step_;

View File

@ -20,6 +20,8 @@
#ifndef OPM_SIMULATORTIMERINTERFACE_HEADER_INCLUDED
#define OPM_SIMULATORTIMERINTERFACE_HEADER_INCLUDED
#include <memory>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
@ -98,6 +100,9 @@ namespace Opm
tm t = boost::posix_time::to_tm(currentDateTime());
return std::mktime(&t);
}
/// return copy of current timer instance
virtual std::unique_ptr< SimulatorTimerInterface > clone () const = 0;
};