DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
pathshop.h
Go to the documentation of this file.
1 #ifndef PATHSHOP_H
2 #define PATHSHOP_H
3 
4 #include <commons_global.h>
5 #include <idtypes.h>
6 
7 #include <memory>
8 #include <string>
9 #include <vector>
10 #include <tuple>
11 
13 {
14  using weight_t = uint16_t;
15 
16  class Private;
17 
18  std::shared_ptr<Private> d;
19 public:
20  class Data {
21  private:
22  types::NodeId node;
23  types::NodeId previous;
24 
25  weight_t weight = 0;
26 
27  public:
28  Data() {}
29 
30  void setNode(types::NodeId n) { node = n; }
31  types::NodeId getNode() const { return node; }
32 
33  void setPreviousNode(types::NodeId n) { previous = n; }
34  types::NodeId getPreviousNode() const { return previous; }
35 
36  void setWeight(weight_t w) { weight = w; }
37  double getWeight() const { return weight; }
38  };
39 
40  class NodeNotFoundException : public std::exception { using exception::exception; };
41 
42  PathShop();
43  virtual ~PathShop() noexcept = default;
44 
45  Data getNode (types::NodeId id) const;
46 
47  static PathShop readFromFiles (const std::string &prevstream, const std::string &weighstream);
48 
49  using InitData = std::tuple<types::NodeId::type, types::NodeId::type, weight_t>;
50  static PathShop readFromData(const std::vector<InitData> &data);
51 };
52 
53 #endif // PATHSHOP_H
void setWeight(weight_t w)
Definition: pathshop.h:36
std::tuple< types::NodeId::type, types::NodeId::type, weight_t > InitData
Definition: pathshop.h:49
Definition: pathshop.h:12
double getWeight() const
Definition: pathshop.h:37
void setPreviousNode(types::NodeId n)
Definition: pathshop.h:33
Definition: pathshop.h:40
Definition: pathshop.cpp:8
Definition: idtypes.h:52
Definition: pathshop.h:20
Definition: pathshop.cpp:23
Definition: idtypes.h:9
void setNode(types::NodeId n)
Definition: pathshop.h:30
types::NodeId getPreviousNode() const
Definition: pathshop.h:34
types::NodeId getNode() const
Definition: pathshop.h:31
Data()
Definition: pathshop.h:28
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23