fpmas-metamodel 1.0
Loading...
Searching...
No Matches
dot.h
Go to the documentation of this file.
1#pragma once
2
3#include "fpmas/api/model/model.h"
4#include "fpmas/io/output.h"
5
7
16class NodeView {
17 public:
21 DistributedId id;
25 int rank;
30 int x;
35 int y;
51 float utility;
52
53 private:
54 // Generic constructor
56 DistributedId id, int rank, bool is_location,
57 float utility, bool fixed_position, int x, int y) :
60 }
61
62 public:
66 NodeView() = default;
67
78 NodeView(DistributedId id, int rank, float utility)
79 : NodeView(id, rank, true, utility, false, {}, {}) {
80 }
90 NodeView(DistributedId id, int rank)
91 : NodeView(id, rank, false, 1.0f, false, {}, {}) {
92 }
93
105 NodeView(DistributedId id, int rank, float utility, int x, int y)
106 : NodeView(id, rank, true, utility, true, x, y) {
107 }
108};
109
113struct EdgeView {
117 DistributedId id;
121 DistributedId src;
125 DistributedId tgt;
129 fpmas::api::graph::LayerId layer;
130
134 EdgeView() = default;
144 DistributedId id, DistributedId src, DistributedId tgt,
145 fpmas::api::graph::LayerId layer)
146 : id(id), src(src), tgt(tgt), layer(layer) {
147 }
148};
149
150namespace nlohmann {
154 template<>
155 struct adl_serializer<NodeView> {
159 static void to_json(nlohmann::json& json, const NodeView& node_view);
163 static void from_json(const nlohmann::json& json, NodeView& node_view);
164 };
165
169 template<>
170 struct adl_serializer<EdgeView> {
174 static void to_json(nlohmann::json& json, const EdgeView& node_view);
178 static void from_json(const nlohmann::json& json, EdgeView& edge_view);
179 };
180}
181
190class DotOutput : public fpmas::io::OutputBase {
191 private:
192 fpmas::io::DynamicFileOutput output_file;
193 BasicMetaModel& meta_model;
194
195 public:
203 BasicMetaModel& meta_model,
204 std::string filename
205 );
206
212 void dump() override;
213};
Definition: metamodel.h:17
Definition: dot.h:190
void dump() override
DotOutput(BasicMetaModel &meta_model, std::string filename)
Definition: dot.h:16
bool fixed_position
Definition: dot.h:47
NodeView()=default
NodeView(DistributedId id, int rank, float utility, int x, int y)
Definition: dot.h:105
bool is_location
Definition: dot.h:39
int rank
Definition: dot.h:25
int y
Definition: dot.h:35
DistributedId id
Definition: dot.h:21
float utility
Definition: dot.h:51
int x
Definition: dot.h:30
NodeView(DistributedId id, int rank, float utility)
Definition: dot.h:78
NodeView(DistributedId id, int rank)
Definition: dot.h:90
Definition: dot.h:113
DistributedId tgt
Definition: dot.h:125
EdgeView()=default
DistributedId src
Definition: dot.h:121
DistributedId id
Definition: dot.h:117
fpmas::api::graph::LayerId layer
Definition: dot.h:129
EdgeView(DistributedId id, DistributedId src, DistributedId tgt, fpmas::api::graph::LayerId layer)
Definition: dot.h:143
static void to_json(nlohmann::json &json, const EdgeView &node_view)
static void from_json(const nlohmann::json &json, EdgeView &edge_view)
static void to_json(nlohmann::json &json, const NodeView &node_view)
static void from_json(const nlohmann::json &json, NodeView &node_view)