ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/GroupChecker.pm
Revision: 1.7
Committed: Fri Dec 14 09:03:43 2007 UTC (17 years, 4 months ago) by muzaffar
Content type: text/plain
Branch: MAIN
CVS Tags: V1_1_7, V1_1_6, V1_1_5, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_1_0, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1
Branch point for: forBinLess_SCRAM
Changes since 1.6: +122 -128 lines
Log Message:
replace head with xml branch

File Contents

# User Rev Content
1 williamc 1.1 #
2     # Maintain a variable to indicate status of a number of requirements
3     #
4     # --------------
5     # Interface
6     #
7     # exclude(gp) : exclude a group
8     # unexclude(gp) : unexclude a group
9     # include(gp) : include a group
10     # uninclude(gp) : uninclude a group
11     # opencontext(gp) : Annonce group context
12 williamc 1.2 # closecontext(gp) : Close group context
13     # closelastcontext(set) : Close the last context added to group the group set
14 williamc 1.1 # status() : If include/excluded groups match the current gp context
15     # return 1 else 0
16     # getincluded() : return an array of included groups
17     # getexcluded() : return array of excluded groups
18 williamc 1.3 # clearinclude() : clear all entries from the include list
19     # clearexclude() : clear all entries from the exclude list
20 williamc 1.1 # ----------------------------------------------
21 williamc 1.2 # group names are characters. Anything before a :: will indicate the
22     # group set upon which the closecontext etc will operate. The group set is
23     # still part of the group name.
24     #
25 williamc 1.1
26     package GroupChecker;
27     require 5.001;
28     require Exporter;
29     @ISA=qw(Exporter);
30    
31 muzaffar 1.7 sub new {
32     my $class=shift;
33     $self={};
34     bless $self, $class;
35     $self->{context}{none}=1;
36     return $self;
37     }
38    
39     sub clearinclude {
40     my $self=shift;
41     undef %{$self->{include}};
42     }
43     sub clearexclude {
44     my $self=shift;
45     undef %{$self->{exclude}};
46     }
47    
48     sub exclude {
49     my $self=shift;
50     my $gp=shift;
51    
52     ${$self->{exclude}}{$gp}=1;
53     $self->_setstatus;
54     }
55    
56     sub unexclude {
57     my $self=shift;
58     my $gp=shift;
59    
60     delete ${$self->{exclude}}{$gp};
61     $self->_setstatus;
62     }
63    
64     sub include {
65     my $self=shift;
66     my $gp=shift;
67    
68     ${$self->{include}}{$gp}=1;
69     $self->_setstatus;
70     }
71    
72     sub uninclude {
73     my $self=shift;
74     my $gp=shift;
75    
76     delete ${$self->{include}}{$gp};
77     $self->_setstatus;
78     }
79    
80     sub getexcluded {
81     my $self=shift;
82     return keys %{$self->{exclude}}
83     }
84    
85     sub getincluded {
86     my $self=shift;
87     return keys %{$self->{include}}
88     }
89    
90     sub opencontext {
91     my $self=shift;
92     my $gp=shift;
93     my $set;
94    
95     if ( $gp=~/(.*)::/ ) {
96     $set=$1;
97     }
98     else {
99     $set='none';
100     }
101 williamc 1.2
102 muzaffar 1.7 push @{$self->{contextstack}{$set}}, $gp;
103     $self->{context}{$gp}=1;
104     $self->_setstatus();
105     }
106    
107     sub closelastcontext {
108     my $self=shift;
109     my $set=shift;
110     my $gp;
111    
112     if ( $set eq "" ) { $set='none' }
113     do {
114     $gp=pop @{$self->{contextstack}{$set}};
115     } while ( (! exists $self->{context}{$gp}) && ($gp eq "") );
116     $self->closecontext($gp);
117     }
118    
119     sub closecontext {
120     my $self=shift;
121     my $gp=shift;
122    
123     if ( $gp=~/(.*)::/ ) {
124     $set=$1;
125     }
126     else {
127     $set='none';
128     }
129     delete $self->{context}{$gp};
130     $self->_setstatus();
131     }
132    
133     sub status {
134     my $self=shift;
135     return $self->{status};
136     }
137    
138     # -------------- Support Routines -----------------------------------
139    
140     sub _setstatus {
141     my $self=shift;
142     my $i;
143 williamc 1.1
144 muzaffar 1.7 $self->{status}=1;
145     foreach $i ( keys %{$self->{context}} ) {
146     if ( ( exists $self->{include}{$i} )
147     || ( exists $self->{include}{all} ) ) {
148     $self->{status}=( $self->{status} && 1);
149     }
150     if ( exists $self->{exclude}{$i} ) {
151     $self->{status}=0;
152     }
153     }
154     }