libsapling  0.8.0
graph.h
Go to the documentation of this file.
1 #ifndef _LIBSAPLING_GRAPH_H_
2 #define _LIBSAPLING_GRAPH_H_
3 
63 #include <stddef.h>
64 #include <stdio.h>
65 #include "libsapling/idiom.h"
66 #include "libsapling/dm/logic.h"
67 
72 struct info_stack {
73  void *user;
74  void *impl;
75 };
76 
92 struct info_insert {
93  size_t size;
94  void *data;
95  void *info;
96 };
97 
98 typedef struct edge_storage *node_t;
99 
112 typedef int (*predicate_t)(const node_t *ref, const struct info_stack *info);
113 
117 typedef void (*apply_t)(node_t *ref, const struct info_stack *info);
118 
124 typedef int (*next_t)(node_t **ref, const struct info_stack *info);
125 
146 typedef void (*edge_management_t)(node_t *ref, const node_t node,
147  void *impl_ptr);
148 
152 typedef void (*fpfdata_t)(FILE *stream, const void *data);
153 
157 typedef void (*fpfnode_t)(FILE *stream, const node_t node, fpfdata_t fpfdata,
158  void *impl_ptr);
159 
167 typedef void (*all_access_adapter_fn)(node_t *ref, void *info, apply_t apply);
168 
173 int predicate_0(UNUSED const node_t *ref,
174  UNUSED const struct info_stack *info);
175 
180 int predicate_1(UNUSED const node_t *ref,
181  UNUSED const struct info_stack *info);
182 
187 void *graph__data(const node_t node, size_t edge_storage);
188 
199 void graph__access(enum qt qt, node_t *ref, const struct info_stack *info,
200  predicate_t predicate, apply_t apply, next_t next);
201 
211 void graph__insert(node_t *ref, const struct info_stack *info,
212  edge_management_t edge_management, size_t edge_storage);
213 
214 
222 void graph__delete(node_t *ref, const struct info_stack *info,
223  edge_management_t edge_management);
224 
228 void graph__print(FILE *stream, node_t *ref,
229  all_access_adapter_fn access_adapter, fpfnode_t fpfnode,
230  fpfdata_t fpfdata);
231 
235 void graph__dump_dot(FILE *stream, node_t *ref,
236  all_access_adapter_fn access_adapter, fpfnode_t fpfnode,
237  fpfdata_t fpfdata, const char *graph_attributes);
238 
243 int graph__length(const node_t *ref, all_access_adapter_fn access_adapter);
244 
245 #endif
void(* apply_t)(node_t *ref, const struct info_stack *info)
Performs a user-defined operation on the node.
Definition: graph.h:117
void graph__access(enum qt qt, node_t *ref, const struct info_stack *info, predicate_t predicate, apply_t apply, next_t next)
Access protocol. Traverses the graph according to a quantifier modifier and specific implementation w...
void(* fpfdata_t)(FILE *stream, const void *data)
File print format data function prototype.
Definition: graph.h:152
int graph__length(const node_t *ref, all_access_adapter_fn access_adapter)
Returns the number of items contained in the set.
int(* predicate_t)(const node_t *ref, const struct info_stack *info)
Decides whether to run the apply function on an item. Behavior is modified by quantifiers.
Definition: graph.h:112
void graph__print(FILE *stream, node_t *ref, all_access_adapter_fn access_adapter, fpfnode_t fpfnode, fpfdata_t fpfdata)
Prints all the data contained in the set.
void graph__delete(node_t *ref, const struct info_stack *info, edge_management_t edge_management)
Deletion protocol.
void * graph__data(const node_t node, size_t edge_storage)
Returns a pointer to the data storage of a node.
void graph__dump_dot(FILE *stream, node_t *ref, all_access_adapter_fn access_adapter, fpfnode_t fpfnode, fpfdata_t fpfdata, const char *graph_attributes)
Dumps the graph in the DOT graph description language.
int predicate_1(UNUSED const node_t *ref, UNUSED const struct info_stack *info)
Trivial predicate function that always returns 1.
int(* next_t)(node_t **ref, const struct info_stack *info)
Chooses the next node to visit.
Definition: graph.h:124
void graph__insert(node_t *ref, const struct info_stack *info, edge_management_t edge_management, size_t edge_storage)
Insertion protocol.
void(* edge_management_t)(node_t *ref, const node_t node, void *impl_ptr)
Called upon the insertion and deletion protocols.
Definition: graph.h:146
void(* fpfnode_t)(FILE *stream, const node_t node, fpfdata_t fpfdata, void *impl_ptr)
File print format node function prototype.
Definition: graph.h:157
void(* all_access_adapter_fn)(node_t *ref, void *info, apply_t apply)
Generic access all nodes adapter function prototype.
Definition: graph.h:167
int predicate_0(UNUSED const node_t *ref, UNUSED const struct info_stack *info)
Trivial predicate function that always returns 0.
#define UNUSED
Decorator to mark unused function parameters.
Definition: idiom.h:11
Logic related definitions.
qt
Quantifier definitions.
Definition: logic.h:10
Information required to perform insertion.
Definition: graph.h:92
void * info
Definition: graph.h:95
void * data
Definition: graph.h:94
size_t size
Definition: graph.h:93
Means of passing arbitrary user and implementation information between function calls.
Definition: graph.h:72