ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/ConfigArea.pm
(Generate patch)

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.29 by sashby, Thu Mar 10 12:39:28 2005 UTC vs.
Revision 1.32 by sashby, Tue Feb 27 12:46:01 2007 UTC

# Line 1 | Line 1
1 < #
2 < # ConfigArea.pm
3 < #
4 < # Written by Christopher Williams
5 < #
6 < # Description
7 < # -----------
8 < # creates and manages a configuration area
9 < #
10 < # Notes
11 < # -------
12 < # Persistency - remember to call the save method to make changes persistent
13 < #
14 < # Interface
15 < # ---------
16 < # new()                         : A new ConfigArea object
17 < # name()                        : get/set project name
18 < # setup(dir[,areaname])         : setup a fresh area in dir
19 < # satellite(dir[,areaname])     : setup a satellite area in dir
20 < # version()                     : get/set project version
21 < # location([dir])               : set/return the location of the work area
22 < # bootstrapfromlocation([location]) : bootstrap the object based on location.
23 < #                                     no location specified - cwd used
24 < #                                     return 0 if succesful 1 otherwise
25 < # requirementsdoc()             : get set the requirements doc
26 < # searchlocation([startdir])    : returns the location directory. search starts
27 < #                                 from cwd if not specified
28 < # scramversion()                : return the scram version associated with
29 < #                                 area
30 < # configurationdir()            : return the location of the project
31 < #                                 configuration directory
32 < # copy(location)                : copy a configuration
33 < # copysetup(location)           : copy the architecture specific tool setup
34 < #                                 returns 0 if successful, 1 otherwise
35 < # copyenv($ref)                 : copy the areas environment into the hashref
36 < # toolbox()                     : return the areas toolbox object
37 < # save()                        : save changes permanently
38 < # linkto(location)              : link the current area to that at location
39 < # unlinkarea()                  : destroy link (autosave)
40 < # linkarea([ConfigArea])        : link the current area to the apec Area Object
41 < # archname()            : get/set a string to indicate architecture
42 < # archdir()             : return the location of the administration arch dep
43 < #                         directory
44 < # objectstore()         : return the objectStore object of the area
45 < # - temporary
46 < # align()                       : adjust hard paths to suit local loaction
1 > =head1 NAME
2 >
3 > Configuration::ConfigArea - Creates and manages a configuration area (i.e. a project area).
4 >
5 > =head1 SYNOPSIS
6 >
7 >        my $obj = Configuration::ConfigArea->new();
8 >
9 > =head1 DESCRIPTION
10 >
11 > Create and manage SCRAM project configuration areas.
12 >
13 > =head1 METHODS
14 >
15 > =over
16 >
17 > =cut
18 >
19 > =item C<new()>
20 >
21 > Create a new Configuration::ConfigArea object.
22 >
23 > =item C<name()>
24 >
25 > Get/set project name.
26 >
27 > =item C<setup($dir[,$areaname])>
28 >
29 > Set up a fresh area in $dir.
30 >
31 > =item C<satellite($dir[,$areaname])>
32 >
33 > Set up a satellite area in $dir.
34 >
35 > =item C<version()>
36 >
37 > Get/set project version.
38 >
39 > =item C<location([$dir])>
40 >
41 > Set/return the location of the work area.
42 >
43 > =item C<bootstrapfromlocation([$location])>
44 >
45 > Bootstrap the object based on location.
46 > No location specified - current directory used
47 > Return 0 if succesful, 1 otherwise.
48 >
49 > =item C<requirementsdoc()>
50 >
51 > Get or set the requirements document.
52 >
53 > =item C<searchlocation([$startdir])>
54 >
55 > Returns the location directory. search starts
56 > from current directory if not specified.
57 >
58 > =item C<scramversion()>
59 >
60 > Return the scram version associated with the area.
61 >
62 > =item C<configurationdir()>
63 >
64 > Return the location of the project configuration directory.
65 >
66 > =item C<copy($location)>
67 >
68 > Copy a configuration from $location.
69 >
70 > =item C<copysetup($location)>
71 >
72 > Copy the architecture-specific tool setup.
73 > Returns 0 if successful, 1 otherwise.
74 >
75 > =item C<copyenv($ref)>
76 >
77 > Copy the area environment into the hashref $ref.
78 >
79 > =item C<toolbox()>
80 >
81 > Return the area toolbox object.
82 >
83 > =item C<save()>
84 >
85 > Save changes permanently.
86 >
87 > =item C<linkto($location)>
88 >
89 > Link the current area to that at location.
90 >
91 > =item C<unlinkarea()>
92 >
93 > Destroy link ($autosave).
94 >
95 > =item C<linkarea([Configuration::ConfigArea])>
96 >
97 > Link the current area to the specified area object.
98 >
99 > =item C<archname()>
100 >
101 > Get/set a string to indicate architecture.
102 >
103 > =item C<archdir()>
104 >
105 > Return the location of the administration
106 > architecture-dependent directory.
107 >
108 > =item C<objectstore()>
109 >
110 > Return the B<objectStore> object of the area temporary.
111 >
112 > =item C<align()>
113 >
114 > Adjust hard paths to suit local location.
115 >
116 >
117 > =back
118 >
119 > =head1 AUTHOR
120 >
121 > Originally written by Christopher Williams.
122 >  
123 > =head1 MAINTAINER
124 >
125 > Shaun ASHBY
126 >
127 > =cut
128  
129   package Configuration::ConfigArea;
130   require 5.004;
# Line 55 | Line 136 | use Cwd;
136   @ISA=qw(Utilities::Verbose);
137  
138   sub new {
139 <        my $class=shift;
140 <        my $self={};
141 <        bless $self, $class;
142 <
143 <        # data init
144 <        $self->{admindir}=".SCRAM";
145 <        $self->{cachedir}="cache";
146 <        $self->{dbdir}="ObjectDB";
147 <        $self->{tbupdate}=0;
148 <        undef $self->{linkarea};
149 <
150 <        return $self;
139 >    my $class=shift;
140 >    my $self={};
141 >    bless $self, $class;
142 >    
143 >    # data init
144 >    $self->{admindir}=".SCRAM";
145 >    $self->{cachedir}="cache";
146 >    $self->{dbdir}="ObjectDB";
147 >    $self->{tbupdate}=0;
148 >    undef $self->{linkarea};
149 >    
150 >    return $self;
151   }
152  
153   sub cache {
154 <        my $self=shift;
155 <
156 <        if ( @_ ) {
157 <           $self->{cache}=shift;
158 <        }
159 <        if ( ! defined $self->{cache} ) {
160 <          my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
161 <          if ( -e $loc  ) {
154 >    my $self=shift;
155 >    
156 >    if ( @_ ) {
157 >        $self->{cache}=shift;
158 >    }
159 >    if ( ! defined $self->{cache} ) {
160 >        my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
161 >        if ( -e $loc  ) {
162              $self->{cache}=URL::URLcache->new($loc);
163 <          }
164 <          else {
163 >        }
164 >        else {
165              $self->{cache}=undef;
85          }
166          }
167 <        return $self->{cache};
167 >    }
168 >    return $self->{cache};
169   }
170  
171   # Tool and project cache info:
# Line 649 | Line 730 | sub _SaveEnvFile
730    
731     undef $fh;
732    
733 +   # Repeat the exercise to save as XML:
734 +   my $fh=FileHandle->new();
735 +   open ( $fh, ">".$self->location()."/".$self->{admindir}."/".
736 +          "Environment.xml" ) or
737 +          $self->error("Cannot Open Environment.xml file to Save ("
738 +                       .$self->location().")\n $!");
739 +   print $fh "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
740 +   print $fh "<doc type=\"Configuration::ProjectEnvironment\" version=\"1.0\">\n";
741 +   print $fh " <environment SCRAM_PROJECTNAME=\"".$self->name()."\"/>\n";
742 +   print $fh " <environment SCRAM_PROJECTVERSION=\"".$self->version()."\"/>\n";
743 +   print $fh " <environment SCRAM_CONFIGDIR=\"".$self->configurationdir()."\"/>\n";
744 +   print $fh " <environment SCRAM_SOURCEDIR=\"".$self->sourcedir()."\"/>\n";
745 +   print $fh " <environment SCRAM_ProjReqsDoc=\"".$self->{reqdoc}."\"/>\n";
746 +   print $fh " <environment SCRAM_TOOLBOXVERSION=\"".$self->{toolboxversion}."\"/>\n";
747 +
748 +   if ( defined $self->linkarea() )
749 +      {
750 +      my $area=$self->linkarea()->location();
751 +      if ( $area ne "" )
752 +         {
753 +         print $fh " <environment RELEASETOP=\"".$area."\"/>\n";
754 +         }
755 +      }
756 +  
757 +   print $fh "</doc>\n";
758 +   undef $fh;
759 +  
760     # Set the default permissions (-rw-r--r--):
761     chmod $filemode, $self->location()."/".$self->{admindir}."/Environment";
762 +   chmod $filemode, $self->location()."/".$self->{admindir}."/Environment.xml";
763     }
764  
765   sub _LoadEnvFile

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines