3
* This file is a part of the Yapgvb software package, and is
4
* licensed under the Common Public License version 1.0. A
5
* `LICENSE' file should have been included with this source.
7
* Copyright (c) 2006 Lonnie Princehouse
11
#ifndef _yapgvb_defined
12
#define _yapgvb_defined
15
#include <boost/python.hpp>
16
#include <boost/python/str.hpp>
17
#include <boost/python/enum.hpp>
18
#include <boost/python/return_value_policy.hpp>
19
#include <boost/python/manage_new_object.hpp>
26
#include <boost/shared_ptr.hpp>
28
using namespace boost::python;
29
using namespace boost;
33
void stop_iteration ();
37
agraphstrict = AGRAPHSTRICT,
38
agdigraph = AGDIGRAPH,
39
agdigraphstrict = AGDIGRAPHSTRICT,
42
// Magical function to reattach graphviz labout attributes to the dictionary
43
// structures. Not listed in any headers because it might go away someday.
46
void attach_attrs(Agraph_t* g);
49
char *extract_str (str s);
53
class AttributeSymbol {
56
AttributeSymbol (Agsym_t *s);
59
void assert_validity ();
63
class AttributeContainer {
68
AttributeContainer ();
69
AttributeContainer (T *p);
74
object get_attribute (AttributeSymbol *s);
75
int set_attribute (AttributeSymbol *s, object value);
77
AttributeSymbol *find_attribute ( str attribute_name );
85
class Edge : public AttributeContainer<Agedge_t> {
92
class Node : public AttributeContainer<Agnode_t> {
97
PyObject *get_name ();
99
Edge *first_inbound_edge ();
100
Edge *next_inbound_edge (Edge *a);
101
Edge *first_outbound_edge ();
102
Edge *next_outbound_edge (Edge *a);
103
Edge *next_edge (Edge *a);
109
class Graph : public AttributeContainer<Agraph_t> {
116
Graph (FILE *instream); // : AttributeContainer<Agraph_t>();
117
Graph (str name); // : AttributeContainer<Agraph_t>();
118
Graph (str name, agraph_type type); // : AttributeContainer<Agraph_t>();
119
Graph (Agraph_t *g, bool is_a_subgraph); // : AttributeContainer<Agraph_t> (g);
120
Graph (Agraph_t *g); // : AttributeContainer<Agraph_t> (g);
124
void debug_file(FILE *f);
126
bool points_to_same_graph (Graph *o);
128
Node *node (str name);
129
Node *find_node (str name);
131
Edge *edge (Node *a, Node *b);
133
Graph *subgraph (str name);
137
AttributeSymbol *declare_graph_attribute(str attribute_name, str default_value);
139
AttributeSymbol *declare_node_attribute(str attribute_name, str default_value);
141
AttributeSymbol *declare_edge_attribute(str attribute_name, str default_value);
143
void set_destroy(bool x);
145
PyObject *get_name ();
147
Edge *find_edge (Node *a, Node *b);
153
Node *next_node (Node *a);
155
Node *previous_node (Node *a);
159
void set_auto_attach(bool a);
160
bool get_auto_attach();
172
// Default constructor
175
int layout(Graph *graph, str engine);
177
int render(Graph *graph, str fmt, FILE *outstream);
179
// Linking to the pre-compiled graphviz library is causing render to not work
180
// on FILE objects which boost has extracted from Python file objects.
182
// Instead of getting to the bottom of this problem, I'm just going to
183
// overload the function in Python and open the file in C.
185
// Maybe someone who actually uses Windows would want to fix this properly?
186
int render_windows_workaround(Graph *graph, str fmt, str out_filename);
188
int freeLayout (Graph *graph);
191
struct pyfile_to_FILE
193
static FILE& execute(PyObject& o)
195
return *PyFile_AsFile(&o);