2 # Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # he Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
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
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 package PciIds::Address::Toplevel;
22 use base 'PciIds::Address::Base';
26 if( $value =~ /^P[CD]\/?/ ) {
27 return bless PciIds::Address::Base::new( $value );
35 if( $self->{'value'} =~ /^PC/ ) {
38 return 'PCI Device Classes';
43 return pretty( shift );
46 sub restrictRex( $$ ) {
47 my( $self, $restrict ) = @_;
48 return PciIds::Address::new( $self->get().'/0000' )->restrictRex( $restrict );#Nasty trick, get the right address of any subnode and try it there
56 my( $self, $suffix ) = @_;
58 if( $self->{'value'} =~ /^PC/ ) {#PCI
59 return ( undef, "Invalid ID syntax" ) unless ( $suffix =~ /^[0-9a-f]{4,4}$/ );
60 } else {#PCI Device Class
61 return ( undef, "Invalid ID syntax" ) unless ( $suffix =~ /^[0-9a-f]{2,2}$/ );
63 return ( PciIds::Address::new( $self->{'value'} . ( ( $self->{'value'} =~ /\/$/ ) ? '' : '/' ) . $suffix ), undef );
66 sub canDiscuss( $ ) { return 0; }
68 sub defaultRestrict( $ ) {
70 if( $self->get() =~ /^PC/ ) {
77 sub defaultRestrictList( $ ) {
79 if( $self->get() =~ /^PC/ ) {
81 for(my $i = '0'; $i < '10'; ++ $i ) {
84 push @result, ( 'a', 'b', 'c', 'd', 'e', 'f' );
86 push @final, [ $_, $_ ] foreach( @result );
87 push @final, [ "", "all" ];
100 if( $self->{'value'} =~ /^PC/ ) {
109 if( $self->get() =~ /^PC/ ) {
112 return 'Device classes';
118 if( $self->get() =~ /^PC/ ) {