| 1 | # This object is used to access the different sections of | ||
| 2 | # classgens control-file. | ||
| 3 | # | ||
| 4 | # Michael Schlueter 15.2.2000 | ||
| 5 | |||
| 6 | |||
| 7 | # 3.03: | ||
| 8 | # The failure, which caused duplicated #-lines in the header | ||
| 9 | # section, has been corrected. 08.12.2000 | ||
| 10 | |||
| 11 | |||
| 12 | # 3.02: | ||
| 13 | # No changes in here 06.07.2000 | ||
| 14 | |||
| 15 | |||
| 16 | package Class::Classgen::Section; | ||
| 17 | |||
| 18 | $VERSION=3.03; | ||
| 19 | |||
| 20 | use Class::Classgen::Comments; # to remove problems by typing errors | ||
| 21 | |||
| 22 | use strict; | ||
| 23 | |||
| 24 | sub new { # constructor | ||
| 25 | my ($self, $id) = @_; | ||
| 26 | my $type = ref($self)||$self; | ||
| 27 | |||
| 28 | # instance-variables | ||
| 29 | my $_identifier; | ||
| 30 | my @_list; | ||
| 31 | |||
| 32 | $self=bless { | ||
| 33 | _id => $_identifier, | ||
| 34 | _list => \@_list, @_list, | ||
| 35 | }, $type; | ||
| 36 | |||
| 37 | $self->set_id($id); | ||
| 38 | return $self; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub add { | ||
| 42 | my ($self, $x) = @_; | ||
| 43 | my $rl = $self->{_list}; | ||
| 44 | # $x =~ s/\s//g unless( $self->get_id() =~ m/head/ ); | ||
| 45 | # push @$rl, $x if( length($x) > 0 ); | ||
| 46 | |||
| 47 | my $a; | ||
| 48 | if( $x=~m/ISA/ ) { | ||
| 49 | $a=$x; | ||
| 50 | } else { | ||
| 51 | $a = Class::Classgen::Comments::just_var($x); | ||
| 52 | } | ||
| 53 | my $b = Class::Classgen::Comments::just_comments($x); | ||
| 54 | $a =~ s/\s//g unless( $self->get_id() =~ m/head/ ); | ||
| 55 | |||
| 56 | if($self->get_id()=~'head') { | ||
| 57 | push @$rl, $a if( length($a) > 0 ); | ||
| 58 | } else { | ||
| 59 | push @$rl, $a.$b if( length($a.$b) > 0 ); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | sub get_id { # access Sections instance variable | ||
| 64 | my ($self) = @_; | ||
| 65 | $self->{_id}; | ||
| 66 | } | ||
| 67 | |||
| 68 | sub get_variables { # access the list of required instance variables | ||
| 69 | my ($self) = @_; | ||
| 70 | my $rl = $self->{_list}; | ||
| 71 | my @list = @$rl; | ||
| 72 | } | ||
| 73 | |||
| 74 | sub set_id { # manipulate Sections instance variable | ||
| 75 | my ($self, $id) = @_; | ||
| 76 | $self->{_id} = $id; | ||
| 77 | } | ||
| 78 | |||
| 79 | sub write_header { | ||
| 80 | my ($self) = @_; | ||
| 81 | |||
| 82 | # case 'header:' | ||
| 83 | # this is the only case allowed to write the class-begining | ||
| 84 | |||
| 85 | if( $self->get_id() =~ m/header/ ) { | ||
| 86 | my @list = $self->get_variables(); | ||
| 87 | return Class::Classgen::Comments::repair_header(@list); | ||
| 88 | # return @list; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | 1; | ||
| 94 | |||
| 95 | |||
| 96 | __END__ |