Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Logging.h
Go to the documentation of this file.
1
31#pragma once
32
33#include <ogdf/basic/Graph.h>
34#include <ogdf/basic/basic.h>
36
37#include <functional>
38#include <ostream>
39#include <string>
40#include <utility>
41
42namespace ogdf {
43class ClusterGraph;
44} // namespace ogdf
45
46#define OGDF_CONTAINER_PRINTER(NAME) \
47 template<typename Container> \
48 struct NAME { \
49 const Container& container; \
50 explicit NAME(const Container& _container) : container(_container) { } \
51 template<typename ContainerT> \
52 friend std::ostream& operator<<(std::ostream& os, const NAME<ContainerT>& inst); \
53 }
54
57OGDF_EXPORT std::string to_string(const std::function<std::ostream&(std::ostream&)>& func);
58
59OGDF_EXPORT std::ostream& operator<<(std::ostream& os,
60 const std::function<std::ostream&(std::ostream&)>& func);
61
62template<typename T1, typename T2>
63std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& pair) {
64 return os << "(" << pair.first << ", " << pair.second << ")";
65}
66
67OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const ogdf::Graph& G);
68
69OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const ogdf::ClusterGraph& CG);
70
71OGDF_CONTAINER_PRINTER(printContainer);
72
73OGDF_CONTAINER_PRINTER(printIncidentEdges);
74
76
77OGDF_CONTAINER_PRINTER(printBijection);
78
79OGDF_CONTAINER_PRINTER(printFrozenBijection);
80
81template<typename Container>
82std::ostream& operator<<(std::ostream& os, const printContainer<Container>& inst) {
83 bool first = true;
84 for (const auto& entry : inst.container) {
85 os << (first ? "" : ", ") << entry;
86 first = false;
87 }
88 return os;
89}
90
91template<typename Container>
92std::ostream& operator<<(std::ostream& os, const printIncidentEdges<Container>& inst) {
93 for (ogdf::adjEntry adj : inst.container) {
94 os << "e" << adj->theEdge()->index() << " (" << (adj->isSource() ? ">" : "<") << "n"
95 << adj->twinNode()->index() << "), ";
96 }
97 return os;
98}
99
100template<>
101std::ostream& operator<<(std::ostream& os, const printIncidentEdges<PipeBij>& inst);
102
103template<typename Container>
104std::ostream& operator<<(std::ostream& os, const printEdges<Container>& inst) {
105 for (ogdf::adjEntry adj : inst.container) {
106 os << "e" << adj->theEdge()->index() << " (n" << adj->theNode()->index()
107 << (adj->isSource() ? "->" : "<-") << "n" << adj->twinNode()->index() << "), ";
108 }
109 return os;
110}
111
112template<>
113std::ostream& operator<<(std::ostream& os, const printEdges<PipeBij>& inst);
114
115template<typename Container>
116std::ostream& operator<<(std::ostream& os, const printBijection<Container>& inst) {
117 bool first = true;
118 for (const std::pair<ogdf::adjEntry, ogdf::adjEntry>& pair : inst.container) {
119 if (first) {
120 first = false;
121 } else {
122 os << " ";
123 }
124 os << "(";
125 if (pair.first == nullptr) {
126 os << "NULL";
127 } else {
128 os << "n" << pair.first->twinNode()->index() << (pair.first->isSource() ? "<" : ">")
129 << " e" << pair.first->theEdge()->index();
130 }
131 os << " = ";
132 if (pair.second == nullptr) {
133 os << "NULL";
134 } else {
135 os << "e" << pair.second->theEdge()->index() << " "
136 << (pair.second->isSource() ? ">" : "<") << "n" << pair.second->twinNode()->index();
137 }
138 os << ")";
139 }
140 return os;
141}
142
143template<typename Container>
144std::ostream& operator<<(std::ostream& os, const printFrozenBijection<Container>& inst) {
145 bool first = true;
146 for (const auto& pair : inst.container) {
147 os << (first ? "" : " ") << "(e" << pair.first << " = e" << pair.second << ")";
148 first = false;
149 }
150 return os;
151}
152
153}
Utilities for working with the bijections between the edges incident to the two endpoints of a Pipe.
Includes declaration of graph class.
#define OGDF_CONTAINER_PRINTER(NAME)
Definition Logging.h:46
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
Representation of clustered graphs.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
all operators will only be found when using sync_plan::internal, so no namespace pollution
Definition SyncPlan.h:82
std::ostream & operator<<(std::ostream &os, const std::function< std::ostream &(std::ostream &)> &func)
std::string to_string(const std::function< std::ostream &(std::ostream &)> &func)
The namespace for all OGDF objects.