### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Control - base class for psgconf control types ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Control; use strict; use PSGConf::Util; ############################################################################### ### constructor ############################################################################### sub new { my ($class, $psgconf, %opts) = @_; my ($self, $caller, $directive); $self = \%opts; bless($self, $class); if ((!exists($self->{name}) || $self->{name} eq '') && ! $self->{quiet}) { $caller = (caller(1))[3] if (!defined($caller)); die "PSGConf::Control->new(): no name attribute from caller $caller\n"; } # Register all our data objects $psgconf->register_data ( $self->{name} . '_enable' => PSGConf::Data::Boolean->new(), $self->{name} . '_packages' => PSGConf::Data::List->new() ); # Register all our policies $psgconf->register_policy ($self, $self->{name} . '_add_packages' => '_policy_add_packages' ); return $self; } ############################################################################### ### policy method ############################################################################### sub _policy_add_packages { my ($self, $psgconf) = @_; my ($enable, $packages); $enable = $self->{name} . '_enable'; $packages = $self->{name} . '_packages'; PSGConf::Util::_add_packages( $psgconf, $psgconf->data_obj($enable)->equals('true'), @{$psgconf->data_obj($packages)->get()} ); } 1; __END__ =head1 NAME PSGConf::Control - base class for PSGConf control types =head1 SYNOPSIS use PSGConf::Control; our @ISA = qw(PSGConf::Control); sub new { my ($class, $psgconf, %opts) = @_; $self = \%opts; bless($self, $class); ... $self = PSGConf::Control->new($psgconf, %$self); return $self; } =head1 DESCRIPTION The B module provides a class that represents an control in B. The B class is not intended to be used to directly instantiate control objects, but it does support the following methods for use in subclasses: =over 4 =item new() The constructor. It can be passed a hash to set the object's attributes. The object will be created as a reference to this hash. The following attributes are supported: =over 4 =item I A B object to store the name of the subclass. It will be used in naming all further data objects. =item I A B object to determine whether or not the control module is to do any work. In future revisions, this will be defined to expicitly turn on or off the item it is controlling. I is to be replaced with the name that the subclass provides. =item I A B object of packages that may need to be installed if this Control module is to be used. I is to be replaced with the name that the subclass provides. =back The constructor also registers the following policy method: =over 4 =item I If I is defined, adds C to the I object, which is provided by the B module. =back =back =head1 SEE ALSO L L L L L L L L L L L =cut