| 1 | #----------------------------------------------------------------- | ||||||||||||||
| 2 | # OWL::Data::Def::ObjectProperty | ||||||||||||||
| 3 | # Author: Edward Kawas <edward.kawas@gmail.com>, | ||||||||||||||
| 4 | # For copyright and disclaimer see below. | ||||||||||||||
| 5 | # | ||||||||||||||
| 6 | # $Id: ObjectProperty.pm,v 1.8 2010-01-07 21:48:08 ubuntu Exp $ | ||||||||||||||
| 7 | #----------------------------------------------------------------- | ||||||||||||||
| 8 | package OWL::Data::Def::ObjectProperty; | ||||||||||||||
| 9 | 2 | ▶ | use base qw( OWL::Base ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | # add versioning to this module | ||||||||||||||
| 13 | 2 | ▶ | use vars qw /$VERSION/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 2 | $VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||
| 15 | |||||||||||||||
| 16 | =head1 NAME | ||||||||||||||
| 17 | |||||||||||||||
| 18 | OWL::Data::Def::ObjectProperty - definition of an owl object property | ||||||||||||||
| 19 | |||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||
| 21 | |||||||||||||||
| 22 | use OWL::Data::Def::ObjectProperty; | ||||||||||||||
| 23 | |||||||||||||||
| 24 | # create a new data type | ||||||||||||||
| 25 | my $datatype = new OWL::Data::Def::ObjectProperty | ||||||||||||||
| 26 | ( name => 'MySequenceProperty', | ||||||||||||||
| 27 | domain => 'http://some.domain.com/MySequenceDomain', | ||||||||||||||
| 28 | uri => 'http://some.domain.com/MySequenceProperty', | ||||||||||||||
| 29 | range => 'http://some.domain.com/MySequence', | ||||||||||||||
| 30 | parent => 'http://some.domain.com/MySequencePropertyParent', | ||||||||||||||
| 31 | ); | ||||||||||||||
| 32 | |||||||||||||||
| 33 | # get the name of this object property | ||||||||||||||
| 34 | print $datatype->name; | ||||||||||||||
| 35 | |||||||||||||||
| 36 | |||||||||||||||
| 37 | =cut | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =head1 DESCRIPTION | ||||||||||||||
| 40 | |||||||||||||||
| 41 | A container representing an OWL object property definition | ||||||||||||||
| 42 | |||||||||||||||
| 43 | =head1 AUTHORS | ||||||||||||||
| 44 | |||||||||||||||
| 45 | Edward Kawas (edward.kawas [at] gmail [dot] com) | ||||||||||||||
| 46 | |||||||||||||||
| 47 | =cut | ||||||||||||||
| 48 | |||||||||||||||
| 49 | #----------------------------------------------------------------- | ||||||||||||||
| 50 | # A list of allowed attribute names. See OWL::Base for details. | ||||||||||||||
| 51 | #----------------------------------------------------------------- | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =head1 ACCESSIBLE ATTRIBUTES | ||||||||||||||
| 54 | |||||||||||||||
| 55 | Details are in L<OWL::Base>. Here just a list of them: | ||||||||||||||
| 56 | |||||||||||||||
| 57 | =over | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =item B<name> | ||||||||||||||
| 60 | |||||||||||||||
| 61 | A name of this object property | ||||||||||||||
| 62 | |||||||||||||||
| 63 | =item B<parent> | ||||||||||||||
| 64 | |||||||||||||||
| 65 | A parent for this object property ... defaults to OWL::Data::OWL::ObjectProperty | ||||||||||||||
| 66 | |||||||||||||||
| 67 | =item B<domain> | ||||||||||||||
| 68 | |||||||||||||||
| 69 | The domain of this object property | ||||||||||||||
| 70 | |||||||||||||||
| 71 | =item B<range> | ||||||||||||||
| 72 | |||||||||||||||
| 73 | The range of this object property | ||||||||||||||
| 74 | |||||||||||||||
| 75 | =item B<uri> | ||||||||||||||
| 76 | |||||||||||||||
| 77 | The uri of this object property | ||||||||||||||
| 78 | |||||||||||||||
| 79 | =back | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =cut | ||||||||||||||
| 82 | |||||||||||||||
| 83 | { | ||||||||||||||
| 84 | my %_allowed = ( | ||||||||||||||
| 85 | name => { | ||||||||||||||
| 86 | # set when we set uri | ||||||||||||||
| 87 | type => OWL::Base->STRING, | ||||||||||||||
| 88 | 0 | ▶ | post => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||
| 89 | 0 | my ($self) = shift; | |||||||||||||
| 90 | my $package = | ||||||||||||||
| 91 | $self->oProperty2module( | ||||||||||||||
| 92 | 0 | $self->uri2package( $self->{name} ) ); | |||||||||||||
| 93 | |||||||||||||||
| 94 | # extract our name and set it | ||||||||||||||
| 95 | 0 | ▶ | my $name = $1 if $package =~ m|\:\:(\w+)$|gi; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 96 | 0 | ▶ | $name = $package unless $name; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 97 | 0 | $self->{name} = $name; | |||||||||||||
| 98 | } | ||||||||||||||
| 99 | }, | ||||||||||||||
| 100 | parent => { | ||||||||||||||
| 101 | type => OWL::Base->STRING, | ||||||||||||||
| 102 | 12 | ▶ | post => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||
| 103 | 12 | my ($self) = shift; | |||||||||||||
| 104 | 12 | my $name = $self->parent; | |||||||||||||
| 105 | $self->{module_parent} = | ||||||||||||||
| 106 | $self->oProperty2module( | ||||||||||||||
| 107 | $self->uri2package( $self->{parent} ) ) | ||||||||||||||
| 108 | 12 | ▶ | unless $self->{parent} eq 'OWL::Data::OWL::ObjectProperty'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 109 | $self->{module_parent} = $self->{parent} | ||||||||||||||
| 110 | 12 | ▶ | if $self->{parent} eq 'OWL::Data::OWL::ObjectProperty'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 111 | }, | ||||||||||||||
| 112 | }, | ||||||||||||||
| 113 | value => { type => OWL::Base->STRING, }, | ||||||||||||||
| 114 | domain => { type => OWL::Base->STRING, }, | ||||||||||||||
| 115 | uri => { | ||||||||||||||
| 116 | type => OWL::Base->STRING, | ||||||||||||||
| 117 | 6 | ▶ | post => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||
| 118 | 6 | my ($self) = shift; | |||||||||||||
| 119 | 6 | my $package = | |||||||||||||
| 120 | $self->oProperty2module( $self->uri2package( $self->uri ) ); | ||||||||||||||
| 121 | 6 | $self->{module_name} = $package; | |||||||||||||
| 122 | |||||||||||||||
| 123 | # extract our name and set it | ||||||||||||||
| 124 | 6 | ▶ | my $name = $1 if $package =~ m|\:\:(\w+)$|gi; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 125 | 6 | ▶ | $name = $package unless $name; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 126 | 6 | $self->{name} = $name; | |||||||||||||
| 127 | } | ||||||||||||||
| 128 | }, | ||||||||||||||
| 129 | 2 | range => { type => OWL::Base->STRING, }, | |||||||||||||
| 130 | |||||||||||||||
| 131 | # used internally (but cannot start with underscore - Template would ignore them) | ||||||||||||||
| 132 | module_name => undef, | ||||||||||||||
| 133 | module_parent => undef, | ||||||||||||||
| 134 | ); | ||||||||||||||
| 135 | |||||||||||||||
| 136 | 14 | ▶ | sub _accessible { | ||||||||||||
|
Subroutine
_accessible: called CC=2 SCAR=7.2
| |||||||||||||||
| 137 | 14 | my ( $self, $attr ) = @_; | |||||||||||||
| 138 | 14 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible($attr); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 139 | } | ||||||||||||||
| 140 | |||||||||||||||
| 141 | 56 | ▶ | sub _attr_prop { | ||||||||||||
|
Subroutine
_attr_prop: called CC=3 SCAR=11.0
| |||||||||||||||
| 142 | 56 | my ( $self, $attr_name, $prop_name ) = @_; | |||||||||||||
| 143 | 56 | my $attr = $_allowed{$attr_name}; | |||||||||||||
| 144 | 56 | ▶ | return ref($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 145 | 16 | return $self->SUPER::_attr_prop( $attr_name, $prop_name ); | |||||||||||||
| 146 | } | ||||||||||||||
| 147 | } | ||||||||||||||
| 148 | |||||||||||||||
| 149 | #----------------------------------------------------------------- | ||||||||||||||
| 150 | |||||||||||||||
| 151 | =head1 SUBROUTINES | ||||||||||||||
| 152 | |||||||||||||||
| 153 | =cut | ||||||||||||||
| 154 | |||||||||||||||
| 155 | #----------------------------------------------------------------- | ||||||||||||||
| 156 | # init | ||||||||||||||
| 157 | #----------------------------------------------------------------- | ||||||||||||||
| 158 | 2 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 159 | 6 | my ($self) = shift; | |||||||||||||
| 160 | 6 | $self->SUPER::init(); | |||||||||||||
| 161 | 6 | $self->parent('OWL::Data::OWL::ObjectProperty'); | |||||||||||||
| 162 | } | ||||||||||||||
| 163 | 2 | 1; | |||||||||||||
| 164 | __END__ | ||||||||||||||