ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/DataItem.pm
Revision: 1.1
Committed: Fri Sep 17 15:40:07 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Log Message:
DataItem Object

File Contents

# User Rev Content
1 williamc 1.1 #
2     # DataItem.pm
3     #
4     # Originally Written by Christopher Williams
5     #
6     # Description
7     # -----------
8     # A data container with a list of lookup keys
9     #
10     # Interface
11     # ---------
12     # new(data,@key) : A new DataItem object with the data matched to a keylist
13     # keys() : return a list of the keys for the data object
14     # data() : return the data for the object
15     # match(@keys) : return 1 if @keys matches those of the data item, else 0
16    
17     package Utilities::DataItem;
18     require 5.001;
19    
20     sub new {
21     my $class=shift;
22     my $data=shift;
23     my @keys=@_;
24    
25     $self={};
26     bless $self, $class;
27     $self->{data}=$data;
28     @{$self->{keys}}=@keys;
29     return $self;
30     }
31    
32     sub keys {
33     my $self=shift;
34     return @{$self->{keys}};
35     }
36    
37     sub data {
38     my $self=shift;
39     return $self->{data};
40     }
41    
42     sub match {
43     my $self=shift;
44     my @keys=@_;
45    
46     my $nm=0;
47    
48     for ( $i=0; $i <= $#keys; $i++ ) {
49     if ( $self->{keys}[$i] eq $keys[$i] ) {
50     $nm++;
51     }
52     }
53     return 1 , if ( $nm > $#keys ); # Succesful match
54     return 0;
55     }