1 | /* -*- Mode: c; c-basic-offset: 2 -*- |
2 | * |
3 | * rdf_storage.h - RDF Storage Factory and Storage interfaces and definitions |
4 | * |
5 | * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/ |
6 | * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/ |
7 | * |
8 | * This package is Free Software and part of Redland http://librdf.org/ |
9 | * |
10 | * It is licensed under the following three licenses as alternatives: |
11 | * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version |
12 | * 2. GNU General Public License (GPL) V2 or any newer version |
13 | * 3. Apache License, V2.0 or any newer version |
14 | * |
15 | * You may not use this file except in compliance with at least one of |
16 | * the above three licenses. |
17 | * |
18 | * See LICENSE.html or LICENSE.txt at the top of this package for the |
19 | * complete terms and further detail along with the license texts for |
20 | * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. |
21 | * |
22 | * |
23 | */ |
24 | |
25 | |
26 | #ifndef LIBRDF_STORAGE_H |
27 | #define LIBRDF_STORAGE_H |
28 | |
29 | #include <rdf_storage_module.h> |
30 | |
31 | #ifdef LIBRDF_INTERNAL |
32 | #include <rdf_storage_internal.h> |
33 | #endif |
34 | |
35 | #ifdef __cplusplus |
36 | extern "C" { |
37 | #endif |
38 | |
39 | /* class methods */ |
40 | REDLAND_API |
41 | int librdf_storage_register_factory(librdf_world *world, const char *name, const char *label, void (*factory) (librdf_storage_factory*)); |
42 | |
43 | REDLAND_API |
44 | int librdf_storage_enumerate(librdf_world* world, const unsigned int counter, const char **name, const char **label); |
45 | |
46 | |
47 | /* constructor */ |
48 | REDLAND_API |
49 | librdf_storage* librdf_new_storage(librdf_world *world, const char *storage_name, const char *name, const char *options_string); |
50 | REDLAND_API |
51 | librdf_storage* librdf_new_storage_with_options(librdf_world *world, const char *storage_name, const char *name, librdf_hash *options); |
52 | REDLAND_API |
53 | librdf_storage* librdf_new_storage_from_storage(librdf_storage* old_storage); |
54 | REDLAND_API |
55 | librdf_storage* librdf_new_storage_from_factory(librdf_world *world, librdf_storage_factory* factory, const char *name, librdf_hash* options); |
56 | |
57 | /* destructor */ |
58 | REDLAND_API |
59 | void librdf_free_storage(librdf_storage *storage); |
60 | |
61 | |
62 | /* methods */ |
63 | REDLAND_API |
64 | void librdf_storage_add_reference(librdf_storage *storage); |
65 | REDLAND_API |
66 | void librdf_storage_remove_reference(librdf_storage *storage); |
67 | |
68 | REDLAND_API |
69 | void librdf_storage_set_instance(librdf_storage *storage, librdf_storage_instance instance); |
70 | REDLAND_API |
71 | librdf_storage_instance librdf_storage_get_instance(librdf_storage *storage); |
72 | |
73 | REDLAND_API |
74 | librdf_world *librdf_storage_get_world(librdf_storage *storage); |
75 | |
76 | REDLAND_API |
77 | int librdf_storage_open(librdf_storage* storage, librdf_model *model); |
78 | REDLAND_API |
79 | int librdf_storage_close(librdf_storage* storage); |
80 | |
81 | REDLAND_API |
82 | int librdf_storage_size(librdf_storage* storage); |
83 | |
84 | REDLAND_API |
85 | int librdf_storage_add_statement(librdf_storage* storage, librdf_statement* statement); |
86 | REDLAND_API |
87 | int librdf_storage_add_statements(librdf_storage* storage, librdf_stream* statement_stream); |
88 | REDLAND_API |
89 | int librdf_storage_remove_statement(librdf_storage* storage, librdf_statement* statement); |
90 | REDLAND_API |
91 | int librdf_storage_contains_statement(librdf_storage* storage, librdf_statement* statement); |
92 | REDLAND_API |
93 | librdf_stream* librdf_storage_serialise(librdf_storage* storage); |
94 | REDLAND_API |
95 | librdf_stream* librdf_storage_find_statements(librdf_storage* storage, librdf_statement* statement); |
96 | REDLAND_API |
97 | librdf_stream* librdf_storage_find_statements_with_options(librdf_storage* storage, librdf_statement* statement, librdf_node* context_node, librdf_hash* options); |
98 | REDLAND_API |
99 | librdf_iterator* librdf_storage_get_sources(librdf_storage *storage, librdf_node *arc, librdf_node *target); |
100 | REDLAND_API |
101 | librdf_iterator* librdf_storage_get_arcs(librdf_storage *storage, librdf_node *source, librdf_node *target); |
102 | REDLAND_API |
103 | librdf_iterator* librdf_storage_get_targets(librdf_storage *storage, librdf_node *source, librdf_node *arc); |
104 | |
105 | |
106 | /* return list of properties to/from a node */ |
107 | REDLAND_API |
108 | librdf_iterator* librdf_storage_get_arcs_in(librdf_storage *storage, librdf_node *node); |
109 | REDLAND_API |
110 | librdf_iterator* librdf_storage_get_arcs_out(librdf_storage *storage, librdf_node *node); |
111 | |
112 | /* check for [node, property, ?] */ |
113 | REDLAND_API |
114 | int librdf_storage_has_arc_in(librdf_storage *storage, librdf_node *node, librdf_node *property); |
115 | /* check for [?, property, node] */ |
116 | REDLAND_API |
117 | int librdf_storage_has_arc_out(librdf_storage *storage, librdf_node *node, librdf_node *property); |
118 | |
119 | /* context methods */ |
120 | REDLAND_API |
121 | int librdf_storage_context_add_statement(librdf_storage* storage, librdf_node* context, librdf_statement* statement); |
122 | REDLAND_API |
123 | int librdf_storage_context_add_statements(librdf_storage* storage, librdf_node* context, librdf_stream* stream); |
124 | REDLAND_API |
125 | int librdf_storage_context_remove_statement(librdf_storage* storage, librdf_node* context, librdf_statement* statement); |
126 | REDLAND_API |
127 | int librdf_storage_context_remove_statements(librdf_storage* storage, librdf_node* context); |
128 | REDLAND_API |
129 | librdf_stream* librdf_storage_context_as_stream(librdf_storage* storage, librdf_node* context); |
130 | REDLAND_API REDLAND_DEPRECATED |
131 | librdf_stream* librdf_storage_context_serialise(librdf_storage* storage, librdf_node* context); |
132 | |
133 | /* querying methods */ |
134 | REDLAND_API |
135 | int librdf_storage_supports_query(librdf_storage* storage, librdf_query *query); |
136 | REDLAND_API |
137 | librdf_query_results* librdf_storage_query_execute(librdf_storage* storage, librdf_query *query); |
138 | |
139 | /* synchronise a storage to the backing store */ |
140 | REDLAND_API |
141 | int librdf_storage_sync(librdf_storage *storage); |
142 | |
143 | /* find statements in a given context */ |
144 | REDLAND_API |
145 | librdf_stream* librdf_storage_find_statements_in_context(librdf_storage* storage, librdf_statement* statement, librdf_node* context_node); |
146 | |
147 | REDLAND_API |
148 | librdf_iterator* librdf_storage_get_contexts(librdf_storage* storage); |
149 | |
150 | /* features */ |
151 | REDLAND_API |
152 | librdf_node* librdf_storage_get_feature(librdf_storage* storage, librdf_uri* feature); |
153 | REDLAND_API |
154 | int librdf_storage_set_feature(librdf_storage* storage, librdf_uri* feature, librdf_node* value); |
155 | |
156 | REDLAND_API |
157 | int librdf_storage_transaction_start(librdf_storage* storage); |
158 | REDLAND_API |
159 | int librdf_storage_transaction_start_with_handle(librdf_storage* storage, void* handle); |
160 | REDLAND_API |
161 | int librdf_storage_transaction_commit(librdf_storage* storage); |
162 | REDLAND_API |
163 | int librdf_storage_transaction_rollback(librdf_storage* storage); |
164 | REDLAND_API |
165 | void* librdf_storage_transaction_get_handle(librdf_storage* storage); |
166 | |
167 | #ifdef __cplusplus |
168 | } |
169 | #endif |
170 | |
171 | #endif |
172 | |