votca 2024.2-dev
Loading...
Searching...
No Matches
graphnode.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#ifndef VOTCA_TOOLS_GRAPHNODE_H
21#define VOTCA_TOOLS_GRAPHNODE_H
22
23// Standard includes
24#include <string>
25#include <unordered_map>
26#include <utility>
27
28// Local VOTCA includes
29#include "types.h"
30
31namespace votca {
32namespace tools {
33
34class GraphDistVisitor;
46class GraphNode {
47 private:
48 std::string str_id_{""};
49 std::unordered_map<std::string, Index> int_vals_;
50 std::unordered_map<std::string, double> double_vals_;
51 std::unordered_map<std::string, std::string> str_vals_;
52 void initStringId_();
53
54 public:
55 GraphNode() = default;
56
59 GraphNode(const std::unordered_map<std::string, Index> int_vals,
60 const std::unordered_map<std::string, double> double_vals,
61 const std::unordered_map<std::string, std::string> str_vals);
62
64 void setInt(const std::unordered_map<std::string, Index> int_vals);
65 void setDouble(const std::unordered_map<std::string, double> double_vals);
66 void setStr(const std::unordered_map<std::string, std::string> str_vals);
67
69 Index getInt(const std::string str);
70 double getDouble(const std::string str);
71 std::string getStr(const std::string str);
72
74 std::string getStringId() const { return str_id_; }
75
76 bool operator==(const GraphNode gn) const;
77 bool operator!=(const GraphNode gn) const;
78
79 // Allow visitor to directly access members of the node
81
82 friend std::ostream& operator<<(std::ostream& os, const GraphNode gn);
83};
84
96bool cmpNode(GraphNode gn1, GraphNode gn2);
97
98} // namespace tools
99} // namespace votca
100#endif // VOTCA_TOOLS_GRAPHNODE_H
A graph node that will take a variety of different values.
Definition graphnode.h:46
std::unordered_map< std::string, std::string > str_vals_
Definition graphnode.h:51
bool operator==(const GraphNode gn) const
Definition graphnode.cc:178
std::string getStringId() const
Get the string id unique to the contents of the graph node.
Definition graphnode.h:74
friend std::ostream & operator<<(std::ostream &os, const GraphNode gn)
Definition graphnode.cc:182
void setDouble(const std::unordered_map< std::string, double > double_vals)
Definition graphnode.cc:137
std::unordered_map< std::string, Index > int_vals_
Definition graphnode.h:49
std::string getStr(const std::string str)
Definition graphnode.cc:165
Index getInt(const std::string str)
Basic getters.
Definition graphnode.cc:147
std::unordered_map< std::string, double > double_vals_
Definition graphnode.h:50
double getDouble(const std::string str)
Definition graphnode.cc:156
bool operator!=(const GraphNode gn) const
Definition graphnode.cc:174
void setStr(const std::unordered_map< std::string, std::string > str_vals)
Definition graphnode.cc:142
void setInt(const std::unordered_map< std::string, Index > int_vals)
Basic setters.
Definition graphnode.cc:132
bool cmpNode(GraphNode gn1, GraphNode gn2)
Comparison function to be used with stl sort algorithm.
Definition graphnode.cc:198
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26