File: AGraph.h

package info (click to toggle)
graphviz 14.0.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 139,388 kB
  • sloc: ansic: 141,938; cpp: 11,957; python: 7,766; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (54 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include <string>
#include <utility>

#include "cgraph.h"

#ifdef GVDLL
#if cgraph___EXPORTS // CMake's substitution of cgraph++_EXPORTS
#define AGRAPH_API __declspec(dllexport)
#else
#define AGRAPH_API __declspec(dllimport)
#endif
#endif

#ifndef AGRAPH_API
#define AGRAPH_API /* nothing */
#endif

namespace CGraph {

/**
 * @brief The AGraph class represents an abstract graph
 */

class AGRAPH_API AGraph {
public:
  explicit AGraph(const std::string &dot);
  ~AGraph();

  // delete copy since we manage a C struct using a raw pointer and the struct
  // cannot be easily copied since it contains even more raw pointers
  AGraph(const AGraph &) = delete;
  AGraph &operator=(const AGraph &) = delete;

  // implement move since we manage a C struct using a raw pointer
  AGraph(AGraph &&other) noexcept : m_g(std::exchange(other.m_g, nullptr)) {}
  AGraph &operator=(AGraph &&other) noexcept {
    using std::swap;
    swap(m_g, other.m_g);
    return *this;
  }

  // get a non-owning pointer to the underlying C data structure
  Agraph_t *c_struct() const { return m_g; }

private:
  // the underlying C data structure
  Agraph_t *m_g = nullptr;
};

} // namespace CGraph

#undef AGRAPH_API