OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
NativeHashGenerator.h
Go to the documentation of this file.
1 #include <vector>
2 #include <string>
3 #include <sstream>
4 #include <functional>
5 #include <algorithm>
6 
13 
14 public:
15 
16  static std::string generate(std::vector<std::string> arguments,
17  size_t world_pid = 0) {
18 
19  std::string hash_input = "";
20 
21  for (const std::string &arg: arguments ) {
22  hash_input += arg;
23  }
24 
25  hash_input += "_" + std::to_string(world_pid);
26 
27  std::hash<std::string> hashFunction;
28  size_t hash_value = hashFunction(hash_input);
29 
30  std::ostringstream hash_str;
31  hash_str << std::hex << hash_value;
32 
33  reverse(hash_input.begin(), hash_input.end());
34  hash_value = hashFunction(hash_input);
35  hash_str << hash_value;
36 
37  return hash_str.str();
38  }
39 
40 private:
41 
44 
45 };
Generates a hash name.
arg(a))
static std::string generate(std::vector< std::string > arguments, size_t world_pid=0)