File: rdf_model_internal.h

package info (click to toggle)
redland 1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 27,592 kB
  • ctags: 12,328
  • sloc: ansic: 79,017; xml: 25,115; sh: 10,162; yacc: 5,985; lex: 3,682; makefile: 3,260; perl: 2,814; cpp: 59
file content (200 lines) | stat: -rw-r--r-- 7,088 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* -*- Mode: c; c-basic-offset: 2 -*-
 *
 * rdf_model_internal.h - Internal RDF Model definitions
 *
 * $Id: rdf_model_internal.h 11704 2006-12-05 04:18:46Z dajobe $
 *
 * Copyright (C) 2000-2006, David Beckett http://purl.org/net/dajobe/
 * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
 * 
 * This package is Free Software and part of Redland http://librdf.org/
 * 
 * It is licensed under the following three licenses as alternatives:
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
 *   2. GNU General Public License (GPL) V2 or any newer version
 *   3. Apache License, V2.0 or any newer version
 * 
 * You may not use this file except in compliance with at least one of
 * the above three licenses.
 * 
 * See LICENSE.html or LICENSE.txt at the top of this package for the
 * complete terms and further detail along with the license texts for
 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
 * 
 * 
 */



#ifndef LIBRDF_MODEL_INTERNAL_H
#define LIBRDF_MODEL_INTERNAL_H

#ifdef __cplusplus
extern "C" {
#endif

struct librdf_model_s {
  librdf_world *world;

  /* usage: usage count of this instance
   *
   * Used by other redland classes such as iterator, stream
   * via librdf_model_add_reference librdf_model_remove_reference
   * The usage count of model after construction is 1.
   */
  int usage;
  
  /* sub_models: list of sub librdf_model* */
  librdf_list*     sub_models;

  /* supports_contexts : does the storage model support redland contexts? */
  int supports_contexts;

  /* context : model implementation user data */
  void *context;

  struct librdf_model_factory_s* factory;
};

/* A Model Factory */
struct librdf_model_factory_s {
  char* name;
  char* label;
  
  /* the rest of this structure is populated by the
     model-specific register function */
  size_t context_length;
  
  /* init the factory */
  void (*init)(void);

  /* terminate the factory */
  void (*terminate)(void);
  
  /* create a new model */
  int (*create)(librdf_model* model, librdf_storage* storage, librdf_hash* options);
  
  /* copy a model */
  /* clone is assumed to do leave the new model in the same state
   * after an init() method on an existing model - i.e ready to
   * use but closed.
   */
  librdf_model* (*clone)(librdf_model* new_model);

  /* destroy model */
  void (*destroy)(librdf_model* model);
  
  /* return the number of statements in the model for model */
  int (*size)(librdf_model* model);
  
  /* add a statement to the model from the given model */
  int (*add_statement)(librdf_model* model, librdf_statement* statement);
  
  /* add a statement to the model from the given model */
  int (*add_statements)(librdf_model* model, librdf_stream* statement_stream);
  
  /* remove a statement from the model  */
  int (*remove_statement)(librdf_model* model, librdf_statement* statement);
  
  /* check if statement in model  */
  int (*contains_statement)(librdf_model* model, librdf_statement* statement);
  /* check for [node, property, ?] */
  int (*has_arc_in)(librdf_model *model, librdf_node *node, librdf_node *property);
  /* check for [?, property, node] */
  int (*has_arc_out)(librdf_model *model, librdf_node *node, librdf_node *property);

  
  /* serialise the model in model  */
  librdf_stream* (*serialise)(librdf_model* model);
  
  /* serialise the results of a query */
  librdf_stream* (*find_statements)(librdf_model* model, librdf_statement* statement);
  librdf_stream* (*find_statements_with_options)(librdf_model* model, librdf_statement* statement, librdf_node* context_node, librdf_hash* options);

  /* return a list of Nodes marching given arc, target */
  librdf_iterator* (*get_sources)(librdf_model* model, librdf_node *arc, librdf_node *target);

  /* return a list of Nodes marching given source, target */
  librdf_iterator* (*get_arcs)(librdf_model* model, librdf_node *source, librdf_node *target);

  /* return a list of Nodes marching given source, target */
  librdf_iterator* (*get_targets)(librdf_model* model, librdf_node *source, librdf_node *target);

  /* return list of properties to/from a node */
  librdf_iterator* (*get_arcs_in)(librdf_model *model, librdf_node *node);
  librdf_iterator* (*get_arcs_out)(librdf_model *model, librdf_node *node);

  /* add a statement to the model from the context */
  int (*context_add_statement)(librdf_model* model, librdf_node* context, librdf_statement *statement);
  
  /* remove a statement from the context  */
  int (*context_remove_statement)(librdf_model* model, librdf_node* context, librdf_statement *statement);

  /* list statements in a context  */
  librdf_stream* (*context_serialize)(librdf_model* model, librdf_node* context);

  /* query the model */
  librdf_query_results* (*query_execute)(librdf_model* model, librdf_query* query);

  /* sync the model to the storage - OPTIONAL */
  int (*sync)(librdf_model* model);

  /* add a statement from the context - OPTIONAL (librdf_model will
   * implement using context_add_statement if missing) 
   */
  int (*context_add_statements)(librdf_model* model, librdf_node* context, librdf_stream *stream);

  /* remove a statement from the context - OPTIONAL (librdf_model will
   * implement using context_remove_statement if missing) 
   */
  int (*context_remove_statements)(librdf_model* model, librdf_node* context);

  /* get the single storage for this model if there is one - OPTIONAL */
  librdf_storage* (*get_storage)(librdf_model* model);

  /* search for statement in a context - OPTIONAL (rdf_model will do
   * it using find_statements if missing)
   */
  librdf_stream* (*find_statements_in_context)(librdf_model* model, librdf_statement* statement, librdf_node* context_node);

  /* return an iterator of context nodes in the store - OPTIONAL
   * (returning NULL)
   */
  librdf_iterator* (*get_contexts)(librdf_model* model);

  /* features - OPTIONAL */
  librdf_node* (*get_feature)(librdf_model* model, librdf_uri* feature);
  int (*set_feature)(librdf_model* model, librdf_uri* feature, librdf_node* value);

  /* transactions - OPTIONAL */
  int (*transaction_start)(librdf_model* model);
  int (*transaction_start_with_handle)(librdf_model* model, void* handle);
  int (*transaction_commit)(librdf_model* model);
  int (*transaction_rollback)(librdf_model* model);
  void* (*transaction_get_handle)(librdf_model* model);

};

/* module init */
void librdf_init_model(librdf_world *world);

  /* module terminate */
void librdf_finish_model(librdf_world *world);

/* class methods */
void librdf_model_register_factory(librdf_world *world, const char *name, const char *label, void (*factory) (librdf_model_factory*));
librdf_model_factory* librdf_get_model_factory(librdf_world* world, const char *name);

void librdf_model_add_reference(librdf_model *model);
void librdf_model_remove_reference(librdf_model *model);


/* model storage factory initialise (the only model factory at present) */
void librdf_init_model_storage(librdf_world *world);


#ifdef __cplusplus
}
#endif

#endif