UMMF::Config::Profile - Configuration Profile object.


UMMF documentation Contained in the UMMF distribution.

Index


Code Index:

NAME

Top

UMMF::Config::Profile - Configuration Profile object.

SYNOPSIS

Top

  my $profile = UMMF::Config::Profile->new('profile' => 'UML-1.5');

  my $value = $profile->config_value($modelElement, $name, $default);

DESCRIPTION

Top

This class is used by bin/ummf.pl to allow the configuration profiles to be reused for different models, particularly for specifing how specific ModelElements may be mapped to implementation language types.

USAGE

Top

  my $value = $profile->config_*($model_element, $key, $default);

EXPORT

Top

None exported.

AUTHOR

Top

Kurt Stephens, kstephens@users.sourceforge.net 2003/10/20

SEE ALSO

Top

UMMF::UML::MetaMetaModel::Config (UMMF::UML::MetaMetaModel::Config)

ummf/profile/*.ummfprofile in lib

VERSION

Top

$Revision: 1.6 $

METHODS

Top


UMMF documentation Contained in the UMMF distribution.

package UMMF::Config::Profile;

use 5.6.0;
use strict;
use warnings;


our $AUTHOR = q{ kstephens@users.sourceforge.net 2003/10/20 };
our $VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d." . "%03d" x $#r, @r };


#######################################################################

use base qw(UMMF::Core::Config);

#######################################################################

use Carp qw(confess);

#######################################################################


sub set_profile
{
  my ($self, $profile) = @_;

  # $DB::single = 1;

  $self->{'profile'} = $profile;
  $self->{'.profile'} = undef;

  $self;
}


#######################################################################


sub override
{
  my ($self) = @_;

  # $DB::single = 1;

  $self->_profile;
}


#######################################################################


sub _profile
{
  my ($self) = @_;

  my $_profile = $self->{'.profile'};

  unless ( $_profile ) {
    my $profile = $self->{'profile'};

    if ( ref($profile) eq 'HASH' ) {
      # $DB::single = 1;

      $_profile = $profile;
    }
    elsif ( $profile ) {
      $profile = [ split(/\s+|\s*,\s*/, $profile) ] unless ref($profile);

      print STDERR "Profile: using profile @$profile\n";

      $profile = join("\n",
		      map(qq{[% PROCESS "$_.ummfprofile" %]},
			  @$profile,
			 )
		     );

      # $DB::single = 1;

      # Use template to process profile.
      my $template = 
	{
	 'INCLUDE_PATH' => [ UMMF->resource_path('profile') ],
	 'INTERPOLATE' => 0,
	 'POST_CHOMP' => 1,
	 'EVAL_PERL' => 1,
	 'DEBUG' => 1,
	 'ABSOLUTE' => 1,
	 'RELATIVE' => 1,
	};

      {
	use Template;
	
	$template = Template->new($template) || confess($Template::ERROR);
      }
      
      # print STDERR "profile = '$profile'\n";

      {
	my $vars = $self;
	my $output = '';
	$template->process(\$profile, $vars, \$output);
	$profile = $output;
      }


      # print STDERR "profile = '$profile'\n";

      {
	use YAML ();

	# $DB::single = 1;
	$_profile = YAML::Load($profile);
      }
    }

    $self->{'.profile'} = $_profile || { };

    # print STDERR Data::Dumper->new([ $_profile ], [ qw($_profile) ])->Dump;
  }


  $_profile;
}


#######################################################################

1;

#######################################################################


### Keep these comments at end of file: kstephens@users.sourceforge.net 2003/10/20 ###
### Local Variables: ###
### mode:perl ###
### perl-indent-level:2 ###
### perl-continued-statement-offset:0 ###
### perl-brace-offset:0 ###
### perl-label-offset:0 ###
### End: ###