Skip to content

Commit

Permalink
Restore use of pointers for client construction.
Browse files Browse the repository at this point in the history
  • Loading branch information
mellis13 committed Nov 4, 2021
1 parent 5e861a1 commit 30b6103
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/SMARTSIM/dump_atom_smartsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@
using namespace LAMMPS_NS;

DumpAtomSmartSim::DumpAtomSmartSim(LAMMPS *lmp, int narg, char **arg)
: DumpAtom(lmp, narg, arg),
_client(_use_cluster())
: DumpAtom(lmp, narg, arg)
{
SmartRedis::Client* client = NULL;
this->_client = NULL;
try {
client = new Client(_use_cluster());
this->_client = client;
}
catch(std::exception& e) {
throw std::runtime_error(e.what());
}
catch(...) {
throw std::runtime_error("A non-standard exception "\
"was encountered during SmartRedis client "\
"construction.");
}
}

/* ---------------------------------------------------------------------- */

DumpAtomSmartSim::~DumpAtomSmartSim()
{
if(this->_client != NULL)
delete this->_client;
}

/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -177,7 +192,7 @@ void DumpAtomSmartSim::write()

/* Send the DataSet to the SmartSim experiment database
*/
this->_client.put_dataset(dataset);
this->_client->put_dataset(dataset);

/* Free temporary memory needed to preprocess LAMMPS output
*/
Expand Down Expand Up @@ -238,12 +253,12 @@ bool DumpAtomSmartSim::_use_cluster()

// Convert the environment variable value to lowercase
char* c = use_cluster;
while((*c)!=0) {
while ((*c) != 0) {
(*c) = std::tolower(*c);
c++;
}

if(std::strcmp(use_cluster, "true")==0)
if (std::strcmp(use_cluster, "true") == 0)
return true;

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/SMARTSIM/dump_atom_smartsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DumpAtomSmartSim : public DumpAtom
private:

// SmartRedis client object
SmartRedis::Client _client;
SmartRedis::Client* _client;

// Function to create a SmartRedis Dataset key
// to prevent key collisions
Expand Down

0 comments on commit 30b6103

Please sign in to comment.