LCOV - code coverage report
Current view: directory - slv2/src - pluginui.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 43 43 100.0 %
Date: 2009-05-26 Functions: 7 7 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 <string.h>
      23                 : #include <stdlib.h>
      24                 : #include "slv2/types.h"
      25                 : #include "slv2/collections.h"
      26                 : #include "slv2_internal.h"
      27                 : 
      28                 : 
      29                 : /* private */
      30                 : SLV2UI
      31                 : slv2_ui_new(SLV2World   world,
      32                 :             librdf_uri* uri,
      33                 :             librdf_uri* type_uri,
      34                 :             librdf_uri* binary_uri)
      35               4 : {
      36               4 :         assert(uri);
      37               4 :         assert(type_uri);
      38               4 :         assert(binary_uri);
      39                 : 
      40               4 :         struct _SLV2UI* ui = malloc(sizeof(struct _SLV2UI));
      41               4 :         ui->world = world;
      42               4 :         ui->uri = slv2_value_new_librdf_uri(world, uri);
      43               4 :         ui->binary_uri = slv2_value_new_librdf_uri(world, binary_uri);
      44                 : 
      45               4 :         assert(ui->binary_uri);
      46                 : 
      47                 :         // FIXME: kludge
      48               4 :         char* bundle = strdup(slv2_value_as_string(ui->binary_uri));
      49               4 :         char* last_slash = strrchr(bundle, '/') + 1;
      50               4 :         *last_slash = '\0';
      51               4 :         ui->bundle_uri = slv2_value_new_uri(world, bundle);
      52               4 :         free(bundle);
      53                 : 
      54               4 :         ui->classes = slv2_values_new();
      55               4 :         raptor_sequence_push(ui->classes, slv2_value_new_librdf_uri(world, type_uri));
      56                 : 
      57               4 :         return ui;
      58                 : }
      59                 : 
      60                 : 
      61                 : /* private */
      62                 : void
      63                 : slv2_ui_free(SLV2UI ui)
      64               4 : {
      65               4 :         slv2_value_free(ui->uri);
      66               4 :         ui->uri = NULL;
      67                 : 
      68               4 :         slv2_value_free(ui->bundle_uri);
      69               4 :         ui->bundle_uri = NULL;
      70                 : 
      71               4 :         slv2_value_free(ui->binary_uri);
      72               4 :         ui->binary_uri = NULL;
      73                 : 
      74               4 :         slv2_values_free(ui->classes);
      75                 : 
      76               4 :         free(ui);
      77               4 : }
      78                 : 
      79                 : 
      80                 : SLV2Value
      81                 : slv2_ui_get_uri(SLV2UI ui)
      82               9 : {
      83               9 :         assert(ui);
      84               9 :         assert(ui->uri);
      85               9 :         return ui->uri;
      86                 : }
      87                 : 
      88                 : 
      89                 : SLV2Values
      90                 : slv2_ui_get_classes(SLV2UI ui)
      91               1 : {
      92               1 :         return ui->classes;
      93                 : }
      94                 : 
      95                 : 
      96                 : bool
      97                 : slv2_ui_is_a(SLV2UI ui, SLV2Value ui_class_uri)
      98               1 : {
      99               1 :         return slv2_values_contains(ui->classes, ui_class_uri);
     100                 : }
     101                 : 
     102                 : 
     103                 : SLV2Value
     104                 : slv2_ui_get_bundle_uri(SLV2UI ui)
     105               1 : {
     106               1 :         assert(ui);
     107               1 :         assert(ui->bundle_uri);
     108               1 :         return ui->bundle_uri;
     109                 : }
     110                 : 
     111                 : 
     112                 : SLV2Value
     113                 : slv2_ui_get_binary_uri(SLV2UI ui)
     114               1 : {
     115               1 :         assert(ui);
     116               1 :         assert(ui->binary_uri);
     117               1 :         return ui->binary_uri;
     118                 : }
     119                 : 

Generated by: LCOV version 1.7