[tracker/wip/sam/resource: 22/22] libtracker-sparql: Start adding meat to tracker-namespace-manager



commit c92f73c6f2ccb6ec7b865e4c968345db9912f41c
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Apr 8 18:16:59 2016 +0100

    libtracker-sparql: Start adding meat to tracker-namespace-manager

 src/libtracker-sparql/tracker-namespace-manager.c |   32 +++++++++++++++++++++
 src/libtracker-sparql/tracker-namespace-manager.h |    2 +
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-namespace-manager.c 
b/src/libtracker-sparql/tracker-namespace-manager.c
index dde9d8b..d7f580d 100644
--- a/src/libtracker-sparql/tracker-namespace-manager.c
+++ b/src/libtracker-sparql/tracker-namespace-manager.c
@@ -32,6 +32,22 @@ typedef struct {
 G_DEFINE_TYPE_WITH_PRIVATE (TrackerNamespaceManager, tracker_namespace_manager, G_TYPE_OBJECT);
 #define GET_PRIVATE(object)  (tracker_namespace_manager_get_instance_private (object))
 
+/**
+ * SECTION: tracker-namespace-manager
+ * @short_description: A set of well-known namespaces, and known abbreviations for them
+ * @title: TrackerNamespaceManager
+ * @stability: Stable
+ * @include: tracker-namespace-manager.h
+ *
+ * <para>
+ * #TrackerNamespaceManager keeps track of namespaces. It allows you to assign
+ * short prefixes for them to avoid typing full URLs all the time.
+ *
+ * Usually you'll want to use the default namespace manager, as returned by
+ * tracker_namespace_manager_get_default(). This knows about all the namespaces
+ * built in to Tracker.
+ * </para>
+ */
 
 static void finalize     (GObject      *object);
 
@@ -66,3 +82,19 @@ tracker_namespace_manager_new ()
 
        namespace_manager = g_object_new (TRACKER_TYPE_NAMESPACE_MANAGER, NULL);
 }
+
+TrackerNamespaceManager *
+tracker_namespace_manager_get_default ()
+{
+       static volatile TrackerNamespaceManager *default_namespace_manager__volatile;
+
+       if (g_once_init_enter (&default_namespace_manager__volatile)) {
+               TrackerNamespaceManager *manager = tracker_namespace_manager_new();
+
+               /* FIXME: populate namespaces from tracker-ontology.h */
+
+               g_once_init_leave (&default_namespace_manager__volatile, manager);
+       }
+
+       return default_namespace_manager__volatile;
+}
diff --git a/src/libtracker-sparql/tracker-namespace-manager.h 
b/src/libtracker-sparql/tracker-namespace-manager.h
index 8d52891..d92e87b 100644
--- a/src/libtracker-sparql/tracker-namespace-manager.h
+++ b/src/libtracker-sparql/tracker-namespace-manager.h
@@ -38,6 +38,8 @@ struct _TrackerNamespaceManagerClass
 
 GType             tracker_namespace_manager_get_type      (void) G_GNUC_CONST;
 
+TrackerNamespaceManager *tracker_namespace_manager_get_default ();
+
 G_END_DECLS
 
 #endif /* __LIBTRACKER_SPARQL_NAMESPACE_MANAGER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]