| 1 | |||||||||||||
| 2 | ### | ||||||||||||
| 3 | # CSS::SAC::Condition::Positional - SAC PositionalConditions | ||||||||||||
| 4 | # Robin Berjon <robin@knowscape.com> | ||||||||||||
| 5 | # 24/02/2001 | ||||||||||||
| 6 | ### | ||||||||||||
| 7 | |||||||||||||
| 8 | package CSS::SAC::Condition::Positional; | ||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use vars qw($VERSION); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | ▶ | $VERSION = $CSS::SAC::VERSION || '0.03'; | ||||||||||
|
Condition50%1/2
$CSS::SAC::VERSION || '0.03'
MC/DC0%0/1
$CSS::SAC::VERSION || '0.03'
$CSS::SAC::VERSION
Truth table50%1/2
A
A= $CSS::SAC::VERSION
| |||||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use base qw(CSS::SAC::Condition); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | |||||||||||||
| 16 | #---------------------------------------------------------------------# | ||||||||||||
| 17 | # build the fields for an array based object | ||||||||||||
| 18 | #---------------------------------------------------------------------# | ||||||||||||
| 19 | 2 | ▶ | use Class::ArrayObjects extend => { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | class => 'CSS::SAC::Condition', | ||||||||||||
| 21 | with => [qw( | ||||||||||||
| 22 | _position_ | ||||||||||||
| 23 | _same_type_ | ||||||||||||
| 24 | _same_node_type_ | ||||||||||||
| 25 | )], | ||||||||||||
| 26 | 2 | }; | |||||||||||
| 27 | #---------------------------------------------------------------------# | ||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | |||||||||||||
| 32 | ### Constructor ####################################################### | ||||||||||||
| 33 | # # | ||||||||||||
| 34 | # # | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | #---------------------------------------------------------------------# | ||||||||||||
| 38 | # CSS::SAC::Condition::Positional->new($type,$position,$node_type,$same_type) | ||||||||||||
| 39 | # creates a new sac PositionalCondition object | ||||||||||||
| 40 | #---------------------------------------------------------------------# | ||||||||||||
| 41 | 14 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||
| 42 | 14 | ▶ | my $class = ref($_[0])?ref(shift):shift; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 14 | my $type = shift; # should be one of the content conditions | |||||||||||
| 44 | 14 | my $position = shift; | |||||||||||
| 45 | 14 | my $same_type = shift; | |||||||||||
| 46 | 14 | my $node_type = shift; | |||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | ### IMPORTANT NOTE ### | ||||||||||||
| 50 | # | ||||||||||||
| 51 | # we will need to parse the new an+b expressions that can be found in | ||||||||||||
| 52 | # positional conditions. In fact, old style simple numbers will be | ||||||||||||
| 53 | # expressed that new way because they can be mapped to it. | ||||||||||||
| 54 | # | ||||||||||||
| 55 | # We'll need to provide for the corresponding accessors. Also, a | ||||||||||||
| 56 | # ->position_matches($pos) method would be cool as it would allow | ||||||||||||
| 57 | # client code to simply ask whether a position matches instead of | ||||||||||||
| 58 | # calculating it itself. | ||||||||||||
| 59 | |||||||||||||
| 60 | |||||||||||||
| 61 | # create a condition | ||||||||||||
| 62 | 14 | my $pcond = $class->SUPER::new($type); | |||||||||||
| 63 | |||||||||||||
| 64 | # add our fields | ||||||||||||
| 65 | 14 | ▶ | $pcond->[_position_] = $position if defined $position; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | 14 | ▶ | $pcond->[_same_type_] = $same_type if defined $same_type; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | 14 | ▶ | $pcond->[_same_node_type_] = $node_type if defined $node_type; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 68 | |||||||||||||
| 69 | 14 | return $pcond; | |||||||||||
| 70 | } | ||||||||||||
| 71 | #---------------------------------------------------------------------# | ||||||||||||
| 72 | |||||||||||||
| 73 | |||||||||||||
| 74 | # # | ||||||||||||
| 75 | # # | ||||||||||||
| 76 | ### Constructor ####################################################### | ||||||||||||
| 77 | |||||||||||||
| 78 | |||||||||||||
| 79 | |||||||||||||
| 80 | ### Accessors ######################################################### | ||||||||||||
| 81 | # # | ||||||||||||
| 82 | # # | ||||||||||||
| 83 | |||||||||||||
| 84 | # aliases | ||||||||||||
| 85 | 2 | *CSS::SAC::Condition::Positional::getPosition = \&Position; | |||||||||||
| 86 | 2 | *CSS::SAC::Condition::Positional::getType = \&Type; | |||||||||||
| 87 | 2 | *CSS::SAC::Condition::Positional::getTypeNode = \&TypeNode; | |||||||||||
| 88 | |||||||||||||
| 89 | |||||||||||||
| 90 | #---------------------------------------------------------------------# | ||||||||||||
| 91 | # my $pos = $pcond->Position() | ||||||||||||
| 92 | # $pcond->Position($pos) | ||||||||||||
| 93 | # get/set the condition's position | ||||||||||||
| 94 | #---------------------------------------------------------------------# | ||||||||||||
| 95 | 14 | ▶ | sub Position { | ||||||||||
|
Subroutine
Position: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 96 | 14 | ▶ | (@_==2) ? $_[0]->[_position_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | $_[0]->[_position_]; | ||||||||||||
| 98 | } | ||||||||||||
| 99 | #---------------------------------------------------------------------# | ||||||||||||
| 100 | |||||||||||||
| 101 | |||||||||||||
| 102 | #---------------------------------------------------------------------# | ||||||||||||
| 103 | # my $bool = $pcond->Type() | ||||||||||||
| 104 | # $pcond->Type($bool) | ||||||||||||
| 105 | # get/set the condition's type constraint | ||||||||||||
| 106 | #---------------------------------------------------------------------# | ||||||||||||
| 107 | 14 | ▶ | sub Type { | ||||||||||
|
Subroutine
Type: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 108 | 14 | ▶ | (@_==2) ? $_[0]->[_same_type_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 109 | $_[0]->[_same_type_]; | ||||||||||||
| 110 | } | ||||||||||||
| 111 | #---------------------------------------------------------------------# | ||||||||||||
| 112 | |||||||||||||
| 113 | |||||||||||||
| 114 | #---------------------------------------------------------------------# | ||||||||||||
| 115 | # my $bool = $pcond->TypeNode() | ||||||||||||
| 116 | # $pcond->TypeNode($bool) | ||||||||||||
| 117 | # get/set the condition's node type constraint | ||||||||||||
| 118 | #---------------------------------------------------------------------# | ||||||||||||
| 119 | 0 | ▶ | sub TypeNode { | ||||||||||
|
Subroutine
TypeNode: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 120 | 0 | ▶ | (@_==2) ? $_[0]->[_same_node_type_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 121 | $_[0]->[_same_node_type_]; | ||||||||||||
| 122 | } | ||||||||||||
| 123 | #---------------------------------------------------------------------# | ||||||||||||
| 124 | |||||||||||||
| 125 | |||||||||||||
| 126 | # # | ||||||||||||
| 127 | # # | ||||||||||||
| 128 | ### Accessors ######################################################### | ||||||||||||
| 129 | |||||||||||||
| 130 | |||||||||||||
| 131 | |||||||||||||
| 132 | 2 | 1; | |||||||||||
| 133 | |||||||||||||
| 134 | =pod | ||||||||||||
| 135 | |||||||||||||
| 136 | =head1 NAME | ||||||||||||
| 137 | |||||||||||||
| 138 | CSS::SAC::Condition::Positional - SAC PositionalConditions | ||||||||||||
| 139 | |||||||||||||
| 140 | =head1 SYNOPSIS | ||||||||||||
| 141 | |||||||||||||
| 142 | see CSS::SAC::Condition | ||||||||||||
| 143 | |||||||||||||
| 144 | =head1 DESCRIPTION | ||||||||||||
| 145 | |||||||||||||
| 146 | This is a subclass of CSS::SAC::Condition, look there for more | ||||||||||||
| 147 | documentation. This class adds the following methods (the spec | ||||||||||||
| 148 | equivalents are available as well, just prepend 'get'): | ||||||||||||
| 149 | |||||||||||||
| 150 | =head1 METHODS | ||||||||||||
| 151 | |||||||||||||
| 152 | =over 4 | ||||||||||||
| 153 | |||||||||||||
| 154 | =item * CSS::SAC::Condition::Positional->new($type,$pos,$node_type,$same_type) | ||||||||||||
| 155 | |||||||||||||
| 156 | =item * $cond->new($type,$pos,$node_type,$same_type) | ||||||||||||
| 157 | |||||||||||||
| 158 | Creates a new positional condition. | ||||||||||||
| 159 | |||||||||||||
| 160 | =item * $pcond->Position([$pos]) | ||||||||||||
| 161 | |||||||||||||
| 162 | get/set the condition's position | ||||||||||||
| 163 | |||||||||||||
| 164 | =item * $pcond->Type([$bool]) | ||||||||||||
| 165 | |||||||||||||
| 166 | get/set the condition's type constraint | ||||||||||||
| 167 | |||||||||||||
| 168 | =item * $pcond->TypeNode([$bool]) | ||||||||||||
| 169 | |||||||||||||
| 170 | get/set the condition's node type constraint | ||||||||||||
| 171 | |||||||||||||
| 172 | =back | ||||||||||||
| 173 | |||||||||||||
| 174 | =head1 AUTHOR | ||||||||||||
| 175 | |||||||||||||
| 176 | Robin Berjon <robin@knowscape.com> | ||||||||||||
| 177 | |||||||||||||
| 178 | This module is licensed under the same terms as Perl itself. | ||||||||||||
| 179 | |||||||||||||
| 180 | =cut | ||||||||||||
| 181 | |||||||||||||
| 182 | |||||||||||||