forked from SWI-Prolog/packages-semweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource.h
55 lines (43 loc) · 1.97 KB
/
resource.h
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
/* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: [email protected]
WWW: http://www.swi-prolog.org
Copyright (C): 2002-2010, VU University Amsterdam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef RESOURCE_H_INCLUDED
#define RESOURCE_H_INCLUDED
#define MAX_RBLOCKS 32
typedef struct resource
{ atom_t name; /* identifier of the resource */
struct resource *next; /* Next in hash */
size_t references; /* #times used */
} resource;
typedef struct resource_hash
{ resource **blocks[MAX_RBLOCKS]; /* Dynamic array starts */
size_t bucket_count; /* Allocated #buckets */
size_t bucket_count_epoch; /* Initial bucket count */
size_t count; /* Total #resources */
} resource_hash;
typedef struct resource_db
{ resource_hash hash; /* Hash atom-->id */
struct rdf_db *db; /* RDF database I belong to */
} resource_db;
COMMON(int) init_resource_db(struct rdf_db *db, resource_db *rdb);
COMMON(void) erase_resources(resource_db *rdb);
COMMON(resource *) lookup_resource(resource_db *rdb, atom_t name);
COMMON(int) register_resource_predicates(void);
COMMON(resource *) register_resource(resource_db *rdb, atom_t name);
COMMON(resource *) unregister_resource(resource_db *rdb, atom_t name);
#endif /*RESOURCE_H_INCLUDED*/