]> mj.ucw.cz Git - pciids.git/blob - PciIds/Address/Base.pm
8b40461dfe3e5921c893176f328bc69e161da249
[pciids.git] / PciIds / Address / Base.pm
1 package PciIds::Address::Base;
2 use strict;
3 use warnings;
4 use PciIds::Address;
5
6 sub new( $ ) {
7         return bless {
8                 'value' => shift
9         }
10 }
11
12 sub get( $ ) {
13         return shift->{'value'};
14 }
15
16 sub parent( $ ) {
17         my( $new ) = ( shift->get() );
18         $new =~ s/[^\/]+\/?$//;
19         return PciIds::Address::new( $new );
20 }
21
22 sub tail( $ ) {
23         my( $new ) = ( shift->get() );
24         $new =~ s/.*\/(.)/$1/;
25         return $new;
26 }
27
28 sub canDiscuss( $ ) {
29         return 1; #By default, comments can be added anywhere
30 }
31
32 sub canAddItem( $ ) { return !shift->leaf(); }
33
34 sub defaultRestrict( $ ) { return "" };
35
36 sub defaultRestrictList( $ ) { return [] };
37
38 sub path( $ ) {
39         my( $self ) = @_;
40         my @result;
41         my $address = $self;
42         while( defined( $address = $address->parent() ) ) {
43                 push @result, $address;
44         }
45         return \@result;
46 }
47
48 sub helpName( $ ) {
49         return undef;
50 }
51
52 sub addressDeps( $ ) {
53         return [];
54 }
55
56 sub top( $ ) {
57         my( $topAd ) = shift->get() =~ /^([^\/]+)/;
58         return PciIds::Address::new( $topAd );
59 }
60
61 1;