Skip to content
Snippets Groups Projects
Commit 534ac2ce authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

unique_ptr: DataFetchingObject

parent 42b6fd0c
No related branches found
No related tags found
No related merge requests found
......@@ -40,11 +40,11 @@ public:
void finishDataGrab();
};
DataFetchingObject* DataFetchingObject::create(unsigned n, PlumedMain& p) {
std::unique_ptr<DataFetchingObject> DataFetchingObject::create(unsigned n, PlumedMain& p) {
if(n==sizeof(double)) {
return new DataFetchingObjectTyped<double>(p);
return std::unique_ptr<DataFetchingObjectTyped<double>>(new DataFetchingObjectTyped<double>(p));
} else if(n==sizeof(float)) {
return new DataFetchingObjectTyped<float>(p);
return std::unique_ptr<DataFetchingObjectTyped<float>>(new DataFetchingObjectTyped<float>(p));
}
std::string pp; Tools::convert(n,pp);
plumed_merror("cannot create an MD interface with sizeof(real)=="+ pp);
......
......@@ -26,6 +26,7 @@
#include <vector>
#include <set>
#include <map>
#include <memory>
namespace PLMD {
......@@ -43,7 +44,7 @@ protected:
/// A copy of the plumed main object
PlumedMain & plumed;
public:
static DataFetchingObject* create(unsigned n, PlumedMain& p);
static std::unique_ptr<DataFetchingObject> create(unsigned n, PlumedMain& p);
/// A constructor so that we can create the plumed main object
explicit DataFetchingObject(PlumedMain&p);
virtual ~DataFetchingObject() {}
......
......@@ -72,6 +72,7 @@ PlumedMain::PlumedMain():
citations_fwd(new Citations),
step(0),
active(false),
mydatafetcher(DataFetchingObject::create(sizeof(double),*this)),
endPlumed(false),
atoms_fwd(new Atoms(*this)),
actionSet_fwd(new ActionSet(*this)),
......@@ -88,7 +89,6 @@ PlumedMain::PlumedMain():
{
log.link(comm);
log.setLinePrefix("PLUMED: ");
mydatafetcher.reset(DataFetchingObject::create(sizeof(double),*this));
stopwatch.start();
stopwatch.pause();
}
......@@ -291,7 +291,7 @@ void PlumedMain::cmd(const std::string & word,void*val) {
CHECK_NOTINIT(initialized,word);
CHECK_NOTNULL(val,word);
atoms.setRealPrecision(*static_cast<int*>(val));
mydatafetcher.reset(DataFetchingObject::create(*static_cast<int*>(val),*this));
mydatafetcher=DataFetchingObject::create(*static_cast<int*>(val),*this);
break;
case cmd_setMDLengthUnits:
CHECK_NOTINIT(initialized,word);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment