[tracker: 10/21] TrackerClass: add the definition position in the ontology




commit 66b457877b93efe061b8c917696744aea1994323
Author: Abanoub Ghadban <abanoub gdb gmail com>
Date:   Wed Aug 18 14:51:11 2021 +0200

    TrackerClass: add the definition position in the ontology
    
    Adds information to TrackerClass class to hold the position in the ontology file where the class is 
defined.
    It adds ontology_path, definition_line_no and definition_column_no to the class.

 src/libtracker-data/tracker-class.c        | 86 ++++++++++++++++++++++++++++++
 src/libtracker-data/tracker-class.h        | 10 ++++
 src/libtracker-data/tracker-data-manager.c |  6 +++
 3 files changed, 102 insertions(+)
---
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c
index 8ad1df4a8..c83879f86 100644
--- a/src/libtracker-data/tracker-class.c
+++ b/src/libtracker-data/tracker-class.c
@@ -40,6 +40,10 @@ struct _TrackerClassPrivate {
        guint notify : 1;
        guint use_gvdb : 1;
 
+       gchar *ontology_path;
+       goffset definition_line_no;
+       goffset definition_column_no;
+
        GMutex mutex;
 
        GArray *super_classes;
@@ -90,6 +94,10 @@ class_finalize (GObject *object)
        g_array_free (priv->super_classes, TRUE);
        g_array_free (priv->domain_indexes, TRUE);
 
+       if (priv->ontology_path) {
+               g_free (priv->ontology_path);
+       }
+
        if (priv->last_domain_indexes) {
                g_array_free (priv->last_domain_indexes, TRUE);
        }
@@ -280,6 +288,42 @@ tracker_class_get_db_schema_changed (TrackerClass *service)
        return priv->db_schema_changed;
 }
 
+const gchar *
+tracker_class_get_ontology_path (TrackerClass *service)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_val_if_fail (TRACKER_IS_CLASS (service), FALSE);
+
+       priv = tracker_class_get_instance_private (service);
+
+       return priv->ontology_path;
+}
+
+goffset
+tracker_class_get_definition_line_no (TrackerClass *service)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_val_if_fail (TRACKER_IS_CLASS (service), FALSE);
+
+       priv = tracker_class_get_instance_private (service);
+
+       return priv->definition_line_no;
+}
+
+goffset
+tracker_class_get_definition_column_no (TrackerClass *service)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_val_if_fail (TRACKER_IS_CLASS (service), FALSE);
+
+       priv = tracker_class_get_instance_private (service);
+
+       return priv->definition_column_no;
+}
+
 void
 tracker_class_set_uri (TrackerClass *service,
                        const gchar  *value)
@@ -471,3 +515,45 @@ tracker_class_set_ontologies (TrackerClass      *class,
        priv = tracker_class_get_instance_private (class);
        priv->ontologies = ontologies;
 }
+
+void
+tracker_class_set_ontology_path (TrackerClass *service,
+                                 const gchar  *value)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_if_fail (TRACKER_IS_CLASS (service));
+
+       priv = tracker_class_get_instance_private (service);
+
+       if (priv->ontology_path)
+               g_free (priv->ontology_path);
+
+       priv->ontology_path = g_strdup (value);
+}
+
+void
+tracker_class_set_definition_line_no (TrackerClass *service,
+                                      goffset       value)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_if_fail (TRACKER_IS_CLASS (service));
+
+       priv = tracker_class_get_instance_private (service);
+
+       priv->definition_line_no = value;
+}
+
+void
+tracker_class_set_definition_column_no (TrackerClass *service,
+                                        goffset       value)
+{
+       TrackerClassPrivate *priv;
+
+       g_return_if_fail (TRACKER_IS_CLASS (service));
+
+       priv = tracker_class_get_instance_private (service);
+
+       priv->definition_column_no = value;
+}
diff --git a/src/libtracker-data/tracker-class.h b/src/libtracker-data/tracker-class.h
index 004c6660c..e806c035f 100644
--- a/src/libtracker-data/tracker-class.h
+++ b/src/libtracker-data/tracker-class.h
@@ -63,6 +63,10 @@ TrackerProperty **tracker_class_get_domain_indexes     (TrackerClass        *ser
 TrackerProperty **tracker_class_get_last_domain_indexes(TrackerClass        *service);
 TrackerClass    **tracker_class_get_last_super_classes (TrackerClass        *service);
 
+const gchar *     tracker_class_get_ontology_path        (TrackerClass      *service);
+goffset           tracker_class_get_definition_line_no   (TrackerClass      *service);
+goffset           tracker_class_get_definition_column_no (TrackerClass      *service);
+
 void              tracker_class_set_uri                (TrackerClass        *service,
                                                         const gchar         *value);
 void              tracker_class_add_super_class        (TrackerClass        *service,
@@ -85,6 +89,12 @@ void              tracker_class_set_notify             (TrackerClass        *ser
 void              tracker_class_set_ontologies         (TrackerClass        *class,
                                                         TrackerOntologies   *ontologies);
 
+void              tracker_class_set_ontology_path        (TrackerClass      *service,
+                                                          const gchar       *value);
+void              tracker_class_set_definition_line_no   (TrackerClass      *service,
+                                                          goffset            value);
+void              tracker_class_set_definition_column_no (TrackerClass      *service,
+                                                          goffset            value);
 G_END_DECLS
 
 #endif /* __LIBTRACKER_DATA_CLASS_H__ */
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index b77921b03..36b6019f8 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -744,6 +744,9 @@ tracker_data_ontology_load_statement (TrackerDataManager  *manager,
                                        tracker_class_reset_domain_indexes (class);
                                        tracker_class_reset_super_classes (class);
                                        tracker_class_set_notify (class, FALSE);
+                                       tracker_class_set_ontology_path (class, ontology_path);
+                                       tracker_class_set_definition_line_no (class, object_line_no);
+                                       tracker_class_set_definition_column_no (class, object_column_no);
                                }
                                goto out;
                        }
@@ -760,6 +763,9 @@ tracker_data_ontology_load_statement (TrackerDataManager  *manager,
                        tracker_class_set_is_new (class, in_update);
                        tracker_class_set_uri (class, subject);
                        tracker_class_set_id (class, subject_id);
+                       tracker_class_set_ontology_path (class, ontology_path);
+                       tracker_class_set_definition_line_no (class, object_line_no);
+                       tracker_class_set_definition_column_no (class, object_column_no);
                        tracker_ontologies_add_class (manager->ontologies, class);
                        tracker_ontologies_add_id_uri_pair (manager->ontologies, subject_id, subject);
 


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