Commit 96f10487 authored by Jens Wehner's avatar Jens Wehner

converted all NULL and 0 to nullptr

parent 48ecb1c4
Pipeline #89437453 failed with stages
in 499 minutes and 56 seconds
......@@ -93,7 +93,7 @@ inline CGMoleculeDef *CGEngine::getMoleculeDef(std::string name) {
}
iter = _molecule_defs.find(name);
if (iter == _molecule_defs.end()) return NULL;
if (iter == _molecule_defs.end()) return nullptr;
return (*iter).second;
}
......
......@@ -36,11 +36,12 @@ namespace csg {
class CGObserver {
public:
/// \brief called before the first frame
virtual void BeginCG(Topology *top, Topology *top_atom = 0) = 0;
virtual void BeginCG(Topology *top, Topology *top_atom = nullptr) = 0;
/// \brief called after the last frame
virtual void EndCG() = 0;
// \brief called for each frame which is mapped
virtual void EvalConfiguration(Topology *top, Topology *top_atom = 0) = 0;
virtual void EvalConfiguration(Topology *top,
Topology *top_atom = nullptr) = 0;
};
} // namespace csg
......
......@@ -68,18 +68,18 @@ class CsgApplication : public tools::Application {
/// \brief called after topology was loaded
virtual bool EvaluateTopology(Topology *top, Topology *top_ref = 0) {
virtual bool EvaluateTopology(Topology *top, Topology *top_ref = nullptr) {
return true;
}
void AddObserver(CGObserver *observer);
/// \brief called before the first frame
virtual void BeginEvaluate(Topology *top, Topology *top_ref = 0);
virtual void BeginEvaluate(Topology *top, Topology *top_ref = nullptr);
/// \brief called after the last frame
virtual void EndEvaluate();
// \brief called for each frame which is mapped
virtual void EvalConfiguration(Topology *top, Topology *top_ref = 0);
virtual void EvalConfiguration(Topology *top, Topology *top_ref = nullptr);
// thread related stuff follows
......@@ -103,7 +103,8 @@ class CsgApplication : public tools::Application {
~Worker() override;
/// \brief overload with the actual computation
virtual void EvalConfiguration(Topology *top, Topology *top_ref = 0) = 0;
virtual void EvalConfiguration(Topology *top,
Topology *top_ref = nullptr) = 0;
/// \brief returns worker id
int getId() { return _id; }
......
......@@ -46,7 +46,7 @@ T *FileFormatFactory<T>::Create(const std::string &file) {
"'" +
file + "' cannot be read or written");
}
return NULL;
return nullptr;
}
} // namespace csg
......
......@@ -85,16 +85,16 @@ inline triple_type *TripleList<element_type, triple_type>::FindTriple(
std::map<element_type, std::map<element_type, triple_type *>>>::iterator
iter1;
iter1 = _triple_map.find(e1);
if (iter1 == _triple_map.end()) return NULL;
if (iter1 == _triple_map.end()) return nullptr;
typename std::map<element_type,
std::map<element_type, triple_type *>>::iterator iter2;
iter2 = iter1->second.find(e2);
if (iter2 == iter1->second.end()) return NULL;
if (iter2 == iter1->second.end()) return nullptr;
typename std::map<element_type, triple_type *>::iterator iter3;
iter3 = iter2->second.find(e3);
if (iter3 == iter2->second.end()) return NULL;
if (iter3 == iter2->second.end()) return nullptr;
return iter3->second;
}
......
......@@ -36,10 +36,11 @@ namespace csg {
**/
class BondedStatistics : public votca::csg::CGObserver {
public:
void BeginCG(Topology *top, Topology *top_atom = 0) override;
void BeginCG(Topology *top, Topology *top_atom = nullptr) override;
void EndCG() override;
void EvalConfiguration(Topology *conf, Topology *conf_atom = 0) override;
void EvalConfiguration(Topology *conf,
Topology *conf_atom = nullptr) override;
TOOLS::DataCollection<double> &BondedValues() { return _bonded_values; }
......
......@@ -86,7 +86,7 @@ void StdAnalysis::WriteValues(BondedStatistics &bs,
std::vector<std::string> &args) {
std::ofstream out;
votca::tools::DataCollection<double>::selection *sel = NULL;
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
sel = bs.BondedValues().select(args[i], sel);
......@@ -102,7 +102,7 @@ void StdAnalysis::WriteValues(BondedStatistics &bs,
void StdAnalysis::WriteAutocorrelation(BondedStatistics &bs,
std::vector<std::string> &args) {
std::ofstream out;
votca::tools::DataCollection<double>::selection *sel = NULL;
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
sel = bs.BondedValues().select(args[i], sel);
......@@ -120,7 +120,7 @@ void StdAnalysis::WriteAutocorrelation(BondedStatistics &bs,
void StdAnalysis::WriteCorrelations(BondedStatistics &bs,
std::vector<std::string> &args) {
std::ofstream out;
votca::tools::DataCollection<double>::selection *sel = NULL;
votca::tools::DataCollection<double>::selection *sel = nullptr;
for (size_t i = 1; i < args.size(); i++)
sel = bs.BondedValues().select(args[i], sel);
......
......@@ -221,7 +221,7 @@ CGMoleculeDef::beaddef_t *CGMoleculeDef::getBeadByName(const string &name) {
map<string, beaddef_t *>::iterator iter = _beads_by_name.find(name);
if (iter == _beads_by_name.end()) {
std::cout << "cannot find: <" << name << "> in " << _name << "\n";
return NULL;
return nullptr;
}
// assert(iter != _beadmap.end());
// return (*iter).second;
......@@ -232,7 +232,7 @@ tools::Property *CGMoleculeDef::getMapByName(const string &name) {
map<string, tools::Property *>::iterator iter = _maps.find(name);
if (iter == _maps.end()) {
std::cout << "cannot find map " << name << "\n";
return NULL;
return nullptr;
}
// assert(iter != _beadmap.end());
// return (*iter).second;
......
......@@ -187,7 +187,7 @@ void CsgApplication::Run(void) {
TopologyReader *reader;
// create reader for atomistic topology
reader = TopReaderFactory().Create(_op_vm["top"].as<std::string>());
if (reader == NULL)
if (reader == nullptr)
throw std::runtime_error(std::string("input format not supported: ") +
_op_vm["top"].as<std::string>());
......@@ -199,7 +199,7 @@ void CsgApplication::Run(void) {
};
// create the master worker
Worker *master = NULL;
Worker *master = nullptr;
if (DoThreaded())
master = ForkWorker();
else
......@@ -264,7 +264,7 @@ void CsgApplication::Run(void) {
// create reader for trajectory
_traj_reader = TrjReaderFactory().Create(_op_vm["trj"].as<std::string>());
if (_traj_reader == NULL)
if (_traj_reader == nullptr)
throw std::runtime_error(std::string("input format not supported: ") +
_op_vm["trj"].as<std::string>());
// open the trajectory
......@@ -412,7 +412,7 @@ void CsgApplication::EvalConfiguration(Topology *top, Topology *top_ref) {
CsgApplication::Worker *CsgApplication::ForkWorker(void) {
throw std::runtime_error("ForkWorker not implemented in application");
return NULL;
return nullptr;
}
void CsgApplication::MergeWorker(CsgApplication::Worker *worker) {
......
......@@ -289,7 +289,7 @@ bool DLPOLYTopologyReader::ReadTopology(string file, Topology &top) {
sl >> line; // internal dlpoly bond/angle/dihedral function types
// are merely skipped (ignored)
int ids[4];
Interaction *ic = NULL;
Interaction *ic = nullptr;
sl >> ids[0];
sl >> ids[1];
if (type == "BONDS") {
......@@ -342,7 +342,7 @@ bool DLPOLYTopologyReader::ReadTopology(string file, Topology &top) {
InteractionContainer ics = mi->Interactions();
for (vector<Interaction *>::iterator ic = ics.begin(); ic != ics.end();
++ic) {
Interaction *ic_replica = NULL;
Interaction *ic_replica = nullptr;
int offset =
mi_replica->getBead(0)->getId() - mi->getBead(0)->getId();
if ((*ic)->BeadCount() == 2) {
......
......@@ -50,7 +50,8 @@ bool GMXTopologyReader::ReadTopology(string file, Topology &top) {
t_inputrec ir;
::matrix gbox;
(void)read_tpx((char *)file.c_str(), &ir, gbox, &natoms, NULL, NULL, &mtop);
(void)read_tpx((char *)file.c_str(), &ir, gbox, &natoms, nullptr, nullptr,
&mtop);
size_t ifirstatom = 0;
......
......@@ -35,8 +35,8 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
int N = conf->BeadCount();
t_trxframe frame;
rvec *x = new rvec[N];
rvec *v = NULL;
rvec *f = NULL;
rvec *v = nullptr;
rvec *f = nullptr;
Eigen::Matrix3d box = conf->getBox();
frame.natoms = N;
......@@ -85,7 +85,7 @@ void GMXTrajectoryWriter::Write(Topology *conf) {
}
}
write_trxframe(_file, &frame, NULL);
write_trxframe(_file, &frame, nullptr);
step++;
delete[] x;
......
......@@ -79,7 +79,7 @@ bool H5MDTrajectoryReader::Open(const string &file) {
first_frame_ = true;
// Handle errors by internal check up.
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
H5Eset_auto2(H5E_DEFAULT, nullptr, nullptr);
return true;
}
......@@ -187,7 +187,7 @@ void H5MDTrajectoryReader::Initialize(Topology &top) {
hid_t fs_atom_position_ = H5Dget_space(ds_atom_position_);
CheckError(fs_atom_position_, "Unable to open atom position space.");
hsize_t dims[3];
rank_ = H5Sget_simple_extent_dims(fs_atom_position_, dims, NULL);
rank_ = H5Sget_simple_extent_dims(fs_atom_position_, dims, nullptr);
N_particles_ = dims[1];
vec_components_ = dims[2];
max_idx_frame_ = dims[0] - 1;
......@@ -237,9 +237,9 @@ bool H5MDTrajectoryReader::NextFrame(Topology &top) { // NOLINT const reference
top.setBox(m);
double *positions;
double *forces = NULL;
double *velocities = NULL;
int *ids = NULL;
double *forces = nullptr;
double *velocities = nullptr;
int *ids = nullptr;
try {
positions = ReadVectorData<double>(ds_atom_position_, H5T_NATIVE_DOUBLE,
......@@ -320,8 +320,8 @@ void H5MDTrajectoryReader::ReadBox(hid_t ds, hid_t ds_data_type, int row,
ch_rows[0] = 1;
ch_rows[1] = 3;
hid_t dsp = H5Dget_space(ds);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, NULL, ch_rows, NULL);
hid_t mspace1 = H5Screate_simple(2, ch_rows, NULL);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, nullptr, ch_rows, nullptr);
hid_t mspace1 = H5Screate_simple(2, ch_rows, nullptr);
herr_t status =
H5Dread(ds, ds_data_type, mspace1, dsp, H5P_DEFAULT, data_out.get());
if (status < 0) {
......
......@@ -75,8 +75,9 @@ class H5MDTrajectoryReader : public TrajectoryReader {
chunk_rows[1] = N_particles_;
chunk_rows[2] = vec_components_;
hid_t dsp = H5Dget_space(ds);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, NULL, chunk_rows, NULL);
hid_t mspace1 = H5Screate_simple(vec_components_, chunk_rows, NULL);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, nullptr, chunk_rows,
nullptr);
hid_t mspace1 = H5Screate_simple(vec_components_, chunk_rows, nullptr);
T1 *data_out = new T1[N_particles_ * vec_components_];
herr_t status =
H5Dread(ds, ds_data_type, mspace1, dsp, H5P_DEFAULT, data_out);
......@@ -97,8 +98,8 @@ class H5MDTrajectoryReader : public TrajectoryReader {
ch_rows[0] = 1;
ch_rows[1] = N_particles_;
hid_t dsp = H5Dget_space(ds);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, NULL, ch_rows, NULL);
hid_t mspace1 = H5Screate_simple(2, ch_rows, NULL);
H5Sselect_hyperslab(dsp, H5S_SELECT_SET, offset, nullptr, ch_rows, nullptr);
hid_t mspace1 = H5Screate_simple(2, ch_rows, nullptr);
T1 *data_out = new T1[N_particles_];
herr_t status =
H5Dread(ds, ds_data_type, mspace1, dsp, H5P_DEFAULT, data_out);
......
......@@ -272,7 +272,7 @@ void XMLTopologyReader::ParseBond(tools::Property &p) {
vector<string> bead_list = tok.ToVector();
if (bead_list.size() % 2 == 1)
throw runtime_error("Wrong number of beads in bond: " + name);
Interaction *ic = NULL;
Interaction *ic = nullptr;
typedef pair<MoleculesMap::iterator, MoleculesMap::iterator> MRange;
int b_index = 0;
for (vector<string>::iterator it = bead_list.begin();
......@@ -309,7 +309,7 @@ void XMLTopologyReader::ParseAngle(tools::Property &p) {
vector<string> bead_list = tok.ToVector();
if (bead_list.size() % 3 == 1)
throw runtime_error("Wrong number of beads in angle: " + name);
Interaction *ic = NULL;
Interaction *ic = nullptr;
typedef pair<MoleculesMap::iterator, MoleculesMap::iterator> MRange;
int b_index = 0;
for (vector<string>::iterator it = bead_list.begin();
......@@ -347,7 +347,7 @@ void XMLTopologyReader::ParseDihedral(tools::Property &p) {
vector<string> bead_list = tok.ToVector();
if (bead_list.size() % 4 == 1)
throw runtime_error("Wrong number of beads in dihedral: " + name);
Interaction *ic = NULL;
Interaction *ic = nullptr;
typedef pair<MoleculesMap::iterator, MoleculesMap::iterator> MRange;
int b_index = 0;
for (vector<string>::iterator it = bead_list.begin();
......
......@@ -21,7 +21,7 @@
namespace votca {
namespace csg {
NBList::NBList() : _do_exclusions(false), _match_function(0) {
NBList::NBList() : _do_exclusions(false), _match_function(nullptr) {
setPairType<BeadPair>();
SetMatchFunction(NBList::match_always);
}
......
......@@ -21,7 +21,7 @@
namespace votca {
namespace csg {
NBList_3Body::NBList_3Body() : _do_exclusions(false), _match_function(0) {
NBList_3Body::NBList_3Body() : _do_exclusions(false), _match_function(nullptr) {
setTripleType<BeadTriple>();
SetMatchFunction(NBList_3Body::match_always);
}
......
......@@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(test_topologyreader) {
string str = "Molecule1.pdb";
reader = TopReaderFactory().Create(str);
reader->ReadTopology(str, top);
BOOST_CHECK_EQUAL(reader != NULL, true);
BOOST_CHECK_EQUAL(reader != nullptr, true);
BOOST_CHECK_EQUAL(top.BeadCount(), 10);
vector<int> resnr = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
......
......@@ -151,7 +151,7 @@ void CGForceMatching::BeginEvaluate(Topology *top, Topology *top_atom) {
_top_force.CopyTopologyData(top);
_trjreader_force =
TrjReaderFactory().Create(_op_vm["trj-force"].as<string>());
if (_trjreader_force == NULL)
if (_trjreader_force == nullptr)
throw runtime_error(string("input format not supported: ") +
_op_vm["trj-force"].as<string>());
// open the trajectory
......
......@@ -55,7 +55,8 @@ class CGForceMatching : public CsgApplication {
/// \brief called after the last frame
void EndEvaluate() override;
/// \brief called for each frame which is mapped
void EvalConfiguration(Topology *conf, Topology *conf_atom = 0) override;
void EvalConfiguration(Topology *conf,
Topology *conf_atom = nullptr) override;
/// \brief load options from the input file
void LoadOptions(const string &file);
......
......@@ -160,7 +160,7 @@ void CsgMapApp::BeginEvaluate(Topology *top, Topology *top_atom) {
string out = OptionsMap()["out"].as<string>();
cout << "writing coarse-grained trajectory to " << out << endl;
_writer = TrjWriterFactory().Create(out);
if (_writer == NULL)
if (_writer == nullptr)
throw runtime_error("output format not supported: " + out);
_do_hybrid = false;
......
......@@ -50,7 +50,7 @@ void check_option(po::options_description &desc, po::variables_map &vm,
int main(int argc, char **argv) {
string in_file, out_file, grid, fitgrid, comment, type, boundaries;
Spline *spline = NULL;
Spline *spline = nullptr;
Table in, out, der;
// program options
po::options_description desc("Allowed options");
......
......@@ -70,7 +70,7 @@ class CsgREupdate : public CsgApplication {
void Initialize() override;
bool EvaluateOptions() override;
void BeginEvaluate(Topology *top, Topology *top_atom = 0) override;
void BeginEvaluate(Topology *top, Topology *top_atom = nullptr) override;
void LoadOptions(const std::string &file);
void Run() override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment