NAME
Data::Startup - startup options class, override, config methods
SYNOPSIS
use Data::Startup
$startup_options = $class->Data::Startup::new( @option_list );
$startup_options = $class->Data::Startup::new( \@option_list );
$startup_options = $class->Data::Startup::new( \%option_list );
$options = $startup_options->override( @option_list );
$options = $startup_options->override( \@option_list );
$options = $startup_options->override( \%option_list );
@options_list = $options->config( );
($key, $old_value) = $options->config($key);
($key, $old_value) = $options->config($key => $new_value );
($key, $old_value) = $options->config($key => $new_value );
@old_options_list = $options->config(@option_list);
@old_options_list = $options->config(\@option_list);
@old_options_list = $options->config(\%option_list);
# Note: May use [@option_list] instead of \@option_list
# and {@option_list} instead of \%option_list
DESCRIPTION
Many times there is a group of subroutines that can be tailored by
different situations with a few, say global variables. However, global
variables pollute namespaces, become mangled when the functions are
multi-threaded and probably have many other faults that it is not worth
the time discovering.
As well documented in literature, object oriented programming do not
have these faults. This program module class of objects provide the
objectized options for a group of subroutines or encapsulated options by
using the methods directly as in an option object.
The "Data::Startup" class provides a way to input options in very
liberal manner of either
* arrays, reference to an array, or reference to hash to a
* reference to an array or reference to a hash
* reference to a hash
* referene to an array
* many other combos
without having to cut and paste specialize, tailored code into each
subroutine/method.
Some of the possiblities follows.
A subroutine may be utilize either as a subroutine or a method of a
object by processing the first argument of @_ by the following:
sub my_suroutine
{
shift if UNIVERSAL::isa($_[0],__PACKAGE__);
# ....
}
The "Data::Startup" class may be used to provide various options syntax
for a dual methods/subroutines as follows:
my $default_options = new( @default_options_list);
# SYNTAX: my_subroutine1($arg1 .. $argn, @options)
# my_subroutine1($arg1 .. $argn, \@options)
# my_subroutine1($arg1 .. $argn, \%options)
#
sub my_subroutine1
{
shift if UNIVERSAL::isa($_[0],__PACKAGE__);
$default_options = Data::Startup->new() unless $default_options;
my ($arg1 .. $argn, @options) = @_
my $options = $default_options->override(@options);
# ....
}
# SYNTAX: my_subroutine2(\@options, @args)
# my_subroutine2(\%options, @args)
#
# !ref($args[0])
sub my_subroutine2
{
shift if UNIVERSAL::isa($_[0],__PACKAGE__);
$default_options = Data::Startup->new() unless $default_options;
my $options = $default_options->override(shift @_) if ref($_[0]);
# ....
}
# SYNTAX: my_subroutine3(\%options, @args)
#
# ref($args[0]) ne 'HASH'
sub my_subroutine3
{
shift if UNIVERSAL::isa($_[0],__PACKAGE__);
$default_options = Data::Startup->new() unless $default_options;
my $options = $default_options->override(shift @_) if ref($_[0] eq 'HASH');
my (@args) = @_;
# ....
}
If program module does not require program module wide global default
options, than still use "Data::Startup" to provide liberal options
syntax as follows
# SYNTAX: my_subroutine1($arg1 .. $argn, @options)
# my_subroutine1($arg1 .. $argn, \@options)
# my_subroutine1($arg1 .. $argn, \%options)
#
sub my_subroutine4
{
shift if UNIVERSAL::isa($_[0],__PACKAGE__);
my ($arg1 .. $argn, @options) = @_
my $options = new Data::Startup(@options);
# ....
}
This technique may be extended to many more different subroutine with a
similar style syntax.
The "Data::Startup" class may be used may also be used to create objects
off a base "$default_object" as follows:
use Data_Startup;
unshift @ISA,'Data_Startup'; # first among classes
use vars qw($default_object);
$default_object = new Data::Startup( @default_list);
sub new
{
$default_options->override( @_ );
}
my $object = new my_package;
my @old_options = object->config( @_ );
my @old_default_options = $my_package::$default_object->config( @_ );
sub method
{
$self = shift;
$value1 = $self->{$key1};
}
And then there are the hybrid subroutine, class syntax and probably some
other possibilies that are not readily apparent.
METHODS
new
The "new" method c<bless> the input "@option_list" creating a default
options hash object.
config
The "config" method reads and writes individual key,value pairs or
groups of key,value pairs in the "$option" object.
The method response with no inputs with all the "$key,$value" pairs in
"$options"; a single "$key" input with the "$key,$value" for that
"$key"; and, a group of "$key, $value" pairs, "@option_list" by
replacing all the "$option" "$key" in the group by the paired <$value>
returning the "@old_options_list" of old "$key,$value" pairs. The
"config" method does not care if the "@option_list" is an array, a
reference to an array or a reference to a hash.
override
The "override" method takes a default options object,
"$startup_options", creates a new duplicate object, "$options", keeping
"$startup_options" intact, and replaces selected optioins in "$options"
with override values, "@option_list".
REQUIREMENTS
Coming.
DEMONSTRATION
#########
# perl Startup.d
###
~~~~~~ Demonstration overview ~~~~~
The results from executing the Perl Code follow on the next lines as
comments. For example,
2 + 2
# 4
~~~~~~ The demonstration follows ~~~~~
use File::Package;
my $uut = 'Data::Startup';
my ($result,@result); # provide scalar and array context
my ($default_options,$options) = ('$default_options','$options');
##################
# create a Data::Startup default options
#
($default_options = new $uut(
perl_secs_numbers => 'multicell',
type => 'ascii',
indent => '',
'Data::SecsPack' => {}
))
# bless( {
# 'perl_secs_numbers' => 'multicell',
# 'Data::SecsPack' => {},
# 'type' => 'ascii',
# 'indent' => ''
# }, 'Data::Startup' )
#
##################
# read perl_secs_numbers default option
#
[$default_options->config('perl_secs_numbers')]
# [
# 'perl_secs_numbers',
# 'multicell'
# ]
#
##################
# write perl_secs_numbers default option
#
[$default_options->config(perl_secs_numbers => 'strict')]
# [
# 'perl_secs_numbers',
# 'multicell'
# ]
#
##################
# restore perl_secs_numbers default option
#
[$default_options->config(perl_secs_numbers => 'multicell')]
# [
# 'perl_secs_numbers',
# 'strict'
# ]
#
##################
# create options copy of default options
#
$options = $default_options->override(type => 'binary')
# bless( {
# 'perl_secs_numbers' => 'multicell',
# 'Data::SecsPack' => {},
# 'type' => 'binary',
# 'indent' => ''
# }, 'Data::Startup' )
#
##################
# verify default options unchanged
#
$default_options
# bless( {
# 'perl_secs_numbers' => 'multicell',
# 'Data::SecsPack' => {},
# 'type' => 'ascii',
# 'indent' => ''
# }, 'Data::Startup' )
#
##################
# array reference option config
#
[@result = $options->config([perl_secs_numbers => 'strict'])]
# [
# 'perl_secs_numbers',
# 'multicell'
# ]
#
##################
# array reference option config
#
$options
# bless( {
# 'perl_secs_numbers' => 'strict',
# 'Data::SecsPack' => {},
# 'type' => 'binary',
# 'indent' => ''
# }, 'Data::Startup' )
#
##################
# hash reference option config
#
[@result = $options->config({'Data::SecsPack'=> {decimal_fraction_digits => 30} })]
# [
# 'Data::SecsPack',
# {}
# ]
#
##################
# hash reference option config
#
$options
# bless( {
# 'perl_secs_numbers' => 'strict',
# 'Data::SecsPack' => {
# 'decimal_fraction_digits' => 30
# },
# 'type' => 'binary',
# 'indent' => ''
# }, 'Data::Startup' )
#
##################
# verify default options still unchanged
#
$default_options
# bless( {
# 'perl_secs_numbers' => 'multicell',
# 'Data::SecsPack' => {},
# 'type' => 'ascii',
# 'indent' => ''
# }, 'Data::Startup' )
#
QUALITY ASSURANCE
Running the test script "Startup.t" verifies the requirements for this
module. The "tmake.pl" cover script for Test::STDmaker automatically
generated the "Startup.t" test script, "Startup.d" demo script, and
"t::Data::Startup" program module POD, from the "t::Data::Startup"
program module contents. The "tmake.pl" cover script automatically ran
the "Startup.d" demo script and inserted the results int the
'DEMONSTRATION' section above. The "t::Data::Startup" program module is
in the distribution file Data-Startup-$VERSION.tar.gz.
NOTES
Author
The holder of the copyright and maintainer is
<
[email protected]>
Copyright Notice
Copyrighted (c) 2002 Software Diamonds
All Rights Reserved
Binding Requirements Notice
Binding requirements are indexed with the pharse 'shall[dd]' where dd is
an unique number for each header section. This conforms to standard
federal government practices, STD490A 3.2.3.6. In accordance with the
License, Software Diamonds is not liable for any requirement, binding or
otherwise.
License
Software Diamonds permits the redistribution and use in source and
binary forms, with or without modification, provided that the following
conditions are met:
1 Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2 Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
SOFTWARE DIAMONDS, http::www.softwarediamonds.com, PROVIDES THIS
SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE
DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE
OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.
SEE ALSO
Docs::Site_SVD::Data_Startup
Test::STDmaker
Title Page
Software Version Description
for
Data::Startup - startup options class, override, config methods
Revision: A
Version: 0.02
Date: 2004/04/29
Prepared for: General Public
Prepared by: SoftwareDiamonds.com E<lt>
[email protected]<gt>
Copyright: copyright � 2003 Software Diamonds
Classification: NONE
1.0 SCOPE
This paragraph identifies and provides an overview of the released
files.
1.1 Identification
This release, identified in 3.2, is a collection of Perl modules that
extend the capabilities of the Perl language.
1.2 System overview
The "Data::Startup" module extends the Perl language (the system).
Many times there is a group of subroutines that can be tailored by
different situations with a few, say global variables. However, global
variables pollute namespaces, become mangled when the functions are
multi-threaded and probably have many other faults that it is not worth
the time discovering.
As well documented in literature, object oriented programming do not
have these faults. This program module class of objects provide the
objectized options for a group of subroutines or encapsulated options by
using the methods directly as in an option object.
1.3 Document overview.
This document releases Data::Startup version 0.02 providing a
description of the inventory, installation instructions and other
information necessary to utilize and track this release.
3.0 VERSION DESCRIPTION
All file specifications in this SVD use the Unix operating system file
specification.
3.1 Inventory of materials released.
This document releases the file
Data-Startup-0.02.tar.gz
found at the following repository(s):
http://www.softwarediamonds/packages/
http://www.perl.com/CPAN/authors/id/S/SO/SOFTDIA/
Restrictions regarding duplication and license provisions are as
follows:
Copyright.
copyright � 2003 Software Diamonds
Copyright holder contact.
603 882-0846 E<lt>
[email protected]<gt>
License.
Software Diamonds permits the redistribution and use in source and
binary forms, with or without modification, provided that the
following conditions are met:
1 Redistributions of source code, modified or unmodified must
retain the above copyright notice, this list of conditions and
the following disclaimer.
2 Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
SOFTWARE DIAMONDS,
http://www.SoftwareDiamonds.com, PROVIDES THIS
SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY
OF SUCH DAMAGE.
3.2 Inventory of software contents
The content of the released, compressed, archieve file, consists of the
following files:
file version date comment
------------------------------------------------------------ ------- ---------- ------------------------
lib/Docs/Site_SVD/Data_Startup.pm 0.02 2004/04/29 new
MANIFEST 0.02 2004/04/29 generated new
Makefile.PL 0.02 2004/04/29 generated new
README 0.02 2004/04/29 generated new
lib/Data/Startup.pm 0.03 2004/04/29 new
t/Data/Startup.d 0.01 2004/04/29 new
t/Data/Startup.pm 0.01 2004/04/29 new
t/Data/Startup.t 0.01 2004/04/29 new
t/Data/File/Package.pm 1.16 2004/04/29 new
t/Data/Test/Tech.pm 1.21 2004/04/29 new
t/Data/Data/Secs2.pm 1.18 2004/04/29 new
t/Data/Data/SecsPack.pm 0.03 2004/04/29 new
3.3 Changes
Changes are as follows:
Data::Startup 0.01
Originated
Data::Startup 0.02
FAILURE:
From: "Thurn, Martin" <
[email protected]>
Date: Thu, 29 Apr 2004 09:21:20 -0400 (EDT)
Subject: FAIL Data-Startup-0.01 sun4-solaris 2.8
I noticed that the test suite seem to fail without these modules:
Data::SecsPack
CORRECTION:
Added "Data::SecsPack" to the test library. The test Perl site lib
only was corrupted and had a "Data::SecsPack" install else c<vmake>
would of failed. Remove "Data::SecsPack" from the test Perl only
site lib.
3.4 Adaptation data.
This installation requires that the installation site has the Perl
programming language installed. There are no other additional
requirements or tailoring needed of configurations files, adaptation
data or other software needed for this installation particular to any
installation site.
3.5 Related documents.
There are no related documents needed for the installation and test of
this release.
3.6 Installation instructions.
Instructions for installation, installation tests and installation
support are as follows:
Installation Instructions.
To installed the release file, use the CPAN module pr PPM module in
the Perl release or the INSTALL.PL script at the following web site:
http://packages.SoftwareDiamonds.com
Follow the instructions for the the chosen installation software.
If all else fails, the file may be manually installed. Enter one of
the following repositories in a web browser:
http://www.softwarediamonds/packages/
http://www.perl.com/CPAN/authors/id/S/SO/SOFTDIA/
Right click on 'Data-Startup-0.02.tar.gz' and download to a
temporary installation directory. Enter the following where $make is
'nmake' for microsoft windows; otherwise 'make'.
gunzip Data-Startup-0.02.tar.gz
tar -xf Data-Startup-0.02.tar
perl Makefile.PL
$make test
$make install
On Microsoft operating system, nmake, tar, and gunzip must be in the
exeuction path. If tar and gunzip are not install, download and
install unxutils from
http://packages.softwarediamonds.com
Prerequistes.
None.
Security, privacy, or safety precautions.
None.
Installation Tests.
Most Perl installation software will run the following test
script(s) as part of the installation:
t/Data/Startup.t
Installation support.
If there are installation problems or questions with the
installation contact
603 882-0846 E<lt>
[email protected]<gt>
3.7 Possible problems and known errors
There are no known open issues.
4.0 NOTES
None.
2.0 SEE ALSO
Data::Startup
ExtUtils::SVDmaker
Docs::US_DOD::SVD