LCOV - code coverage report
Current view: directory - slv2/src - pluginclass.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 31 31 100.0 %
Date: 2009-05-26 Functions: 6 6 100.0 %

       1                 : /* SLV2
       2                 :  * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net>
       3                 :  *
       4                 :  * This library is free software; you can redistribute it and/or modify it
       5                 :  * under the terms of the GNU General Public License as published by the Free
       6                 :  * Software Foundation; either version 2 of the License, or (at your option)
       7                 :  * any later version.
       8                 :  *
       9                 :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10                 :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11                 :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      12                 :  * for more details.
      13                 :  *
      14                 :  * You should have received a copy of the GNU General Public License along
      15                 :  * with this program; if not, write to the Free Software Foundation, Inc.,
      16                 :  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
      17                 :  */
      18                 : 
      19                 : #define _XOPEN_SOURCE 500
      20                 : 
      21                 : #include <assert.h>
      22                 : #include <stdlib.h>
      23                 : #include <string.h>
      24                 : #include "slv2/types.h"
      25                 : #include "slv2/pluginclass.h"
      26                 : #include "slv2/value.h"
      27                 : #include "slv2_internal.h"
      28                 : 
      29                 : 
      30                 : /* private */
      31                 : SLV2PluginClass
      32                 : slv2_plugin_class_new(SLV2World world, librdf_uri* parent_uri, librdf_uri* uri, const char* label)
      33             415 : {
      34             415 :         SLV2PluginClass pc = (SLV2PluginClass)malloc(sizeof(struct _SLV2PluginClass));
      35             415 :         pc->world = world;
      36             415 :         pc->parent_uri = (parent_uri ? slv2_value_new_librdf_uri(world, parent_uri) : NULL);
      37             415 :         pc->uri = slv2_value_new_librdf_uri(world, uri);
      38             415 :         pc->label = slv2_value_new(world, SLV2_VALUE_STRING, label);
      39             415 :         return pc;
      40                 : }
      41                 : 
      42                 : 
      43                 : void
      44                 : slv2_plugin_class_free(SLV2PluginClass plugin_class)
      45             415 : {
      46             415 :         assert(plugin_class->uri);
      47             415 :         slv2_value_free(plugin_class->uri);
      48             415 :         slv2_value_free(plugin_class->parent_uri);
      49             415 :         slv2_value_free(plugin_class->label);
      50             415 :         free(plugin_class);
      51             415 : }
      52                 : 
      53                 : 
      54                 : SLV2Value
      55                 : slv2_plugin_class_get_parent_uri(SLV2PluginClass plugin_class)
      56              57 : {
      57              57 :         if (plugin_class->parent_uri)
      58              56 :                 return plugin_class->parent_uri;
      59                 :         else
      60               1 :                 return NULL;
      61                 : }
      62                 : 
      63                 : 
      64                 : SLV2Value
      65                 : slv2_plugin_class_get_uri(SLV2PluginClass plugin_class)
      66              72 : {
      67              72 :         assert(plugin_class->uri);
      68              72 :         return plugin_class->uri;
      69                 : }
      70                 : 
      71                 : 
      72                 : SLV2Value
      73                 : slv2_plugin_class_get_label(SLV2PluginClass plugin_class)
      74               1 : {
      75               1 :         return plugin_class->label;
      76                 : }
      77                 : 
      78                 : 
      79                 : SLV2PluginClasses
      80                 : slv2_plugin_class_get_children(SLV2PluginClass plugin_class)
      81               1 : {
      82                 :         // Returned list doesn't own categories
      83               1 :         SLV2PluginClasses result = raptor_new_sequence(NULL, NULL);
      84                 : 
      85              46 :         for (int i=0; i < raptor_sequence_size(plugin_class->world->plugin_classes); ++i) {
      86              45 :                 SLV2PluginClass c = raptor_sequence_get_at(plugin_class->world->plugin_classes, i);
      87              45 :                 SLV2Value parent = slv2_plugin_class_get_parent_uri(c);
      88              45 :                 if (parent && slv2_value_equals(slv2_plugin_class_get_uri(plugin_class), parent))
      89              11 :                         raptor_sequence_push(result, c);
      90                 :         }
      91                 : 
      92               1 :         return result;
      93                 : }

Generated by: LCOV version 1.7