forked from AravisProject/aravis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arvdomimplementation.c
86 lines (72 loc) · 2.4 KB
/
arvdomimplementation.c
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
/* Aravis - Digital camera library
*
* Copyright © 2009-2022 Emmanuel Pacaud
*
* 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 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author:
* Emmanuel Pacaud <[email protected]>
*/
#include <arvdomimplementation.h>
#include <arvdebugprivate.h>
#include <arvgc.h>
#include <string.h>
static GHashTable *document_types = NULL;
void
arv_dom_implementation_add_document_type (const char *qualified_name,
GType document_type)
{
GType *document_type_ptr;
if (document_types == NULL)
document_types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
document_type_ptr = g_new (GType, 1);
*document_type_ptr = document_type;
g_hash_table_insert (document_types, g_strdup (qualified_name), document_type_ptr);
}
/**
* arv_dom_implementation_create_document:
* @namespace_uri: namespace URI
* @qualified_name: qualified name
*
* Create a new DOM document. Currently, only @qualified_name is used.
*
* Returns: (transfer full): a new #ArvDomDocument, NULL on error:
*/
ArvDomDocument *
arv_dom_implementation_create_document (const char *namespace_uri,
const char *qualified_name)
{
GType *document_type;
g_return_val_if_fail (qualified_name != NULL, NULL);
if (document_types == NULL) {
arv_dom_implementation_add_document_type ("RegisterDescription", ARV_TYPE_GC);
}
document_type = g_hash_table_lookup (document_types, qualified_name);
if (document_type == NULL) {
arv_info_dom ("[ArvDomImplementation::create_document] Unknown document type (%s)",
qualified_name);
return NULL;
}
return g_object_new (*document_type, NULL);
}
void
arv_dom_implementation_cleanup (void)
{
if (document_types == NULL)
return;
g_hash_table_unref (document_types);
document_types = NULL;
}