tracker-0.16.2/docs/tools/ttl_model.c

No issues found

  1 /*
  2  * Copyright (C) 2009, Nokia <ivan.frade@nokia.com>
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU General Public License
  6  * as published by the Free Software Foundation; either version 2
  7  * of the License, or (at your option) any later version.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  * GNU General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 17  * 02110-1301, USA.
 18  */
 19 
 20 #include "ttl_model.h"
 21 
 22 OntologyClass *
 23 ttl_model_class_new (const gchar *classname)
 24 {
 25 	OntologyClass *def = NULL;
 26 
 27 	def = g_new0 (OntologyClass, 1);
 28 
 29 	def->classname = g_strdup (classname);
 30 	def->superclasses = NULL;
 31 	def->subclasses = NULL;
 32 	def->in_domain_of = NULL;
 33 	def->in_range_of = NULL;
 34 	def->description = NULL;
 35 	def->instances = NULL;
 36 	def->notify = FALSE;
 37 	def->deprecated = FALSE;
 38 
 39 	return def;
 40 }
 41 
 42 void
 43 ttl_model_class_free (OntologyClass *def)
 44 {
 45 	g_free (def->classname);
 46 
 47 	g_list_foreach (def->superclasses, (GFunc) g_free, NULL);
 48 	g_list_foreach (def->subclasses, (GFunc) g_free, NULL);
 49 	g_list_foreach (def->in_domain_of, (GFunc) g_free, NULL);
 50 	g_list_foreach (def->in_range_of, (GFunc) g_free, NULL);
 51 
 52 	g_free (def->description);
 53 
 54 	g_list_foreach (def->instances, (GFunc) g_free, NULL);
 55 
 56 	g_free (def);
 57 }
 58 
 59 OntologyProperty *
 60 ttl_model_property_new (const gchar *propname)
 61 {
 62 	OntologyProperty *prop;
 63 
 64 	prop = g_new0 (OntologyProperty, 1);
 65 
 66 	prop->propertyname = g_strdup (propname);
 67 	prop->type = NULL;
 68 	prop->domain = NULL;
 69 	prop->range = NULL;
 70 	prop->superproperties = NULL;
 71 	prop->subproperties = NULL;
 72 	prop->max_cardinality = NULL;
 73 	prop->description = NULL;
 74 	prop->deprecated = FALSE;
 75 	prop->fulltextIndexed = FALSE ;
 76 	prop->weight = NULL;
 77 
 78 	return prop;
 79 }
 80 
 81 void
 82 ttl_model_property_free (OntologyProperty *def)
 83 {
 84 	g_free (def->propertyname);
 85 
 86 	g_list_foreach (def->type, (GFunc) g_free, NULL);
 87 	g_list_foreach (def->domain, (GFunc) g_free, NULL);
 88 	g_list_foreach (def->range, (GFunc) g_free, NULL);
 89 	g_list_foreach (def->superproperties, (GFunc) g_free, NULL);
 90 	g_list_foreach (def->subproperties, (GFunc) g_free, NULL);
 91 
 92 	g_free (def->max_cardinality);
 93 	g_free (def->description);
 94 	g_free (def->weight);
 95 	g_free (def);
 96 }
 97 
 98 OntologyDescription *
 99 ttl_model_description_new (void)
100 {
101 	OntologyDescription *desc;
102 
103 	desc = g_new0 (OntologyDescription, 1);
104 	desc->title = NULL;
105 	desc->authors = NULL;
106 	desc->editors = NULL;
107 	desc->contributors = NULL;
108 	desc->gitlog = NULL;
109 	desc->upstream = NULL;
110 	desc->copyright = NULL;
111 	desc->baseUrl = NULL;
112 	desc->localPrefix = NULL;
113 	desc->relativePath = NULL;
114 	return desc;
115 }
116 
117 void
118 ttl_model_description_free (OntologyDescription *desc)
119 {
120 	g_free (desc->title);
121 
122 	g_list_foreach (desc->authors, (GFunc)g_free, NULL);
123 	g_list_foreach (desc->editors, (GFunc)g_free, NULL);
124 	g_list_foreach (desc->contributors, (GFunc)g_free, NULL);
125 
126 	g_free (desc->gitlog);
127 	g_free (desc->upstream);
128 	g_free (desc->copyright);
129 
130 	g_free (desc->baseUrl);
131 	g_free (desc->relativePath);
132 	g_free (desc->localPrefix);
133 
134 	g_free (desc);
135 }