  | 
 
 
 
 |  
 |  | 
 
  
    | Class::MethodMapper(3) | 
    User Contributed Perl Documentation | 
    Class::MethodMapper(3) | 
   
 
Class::MethodMapper - Abstract Class wrapper for AutoLoader 
  BEGIN {
    @MMDerived::ISA = qw(Class::MethodMapper 
                                  Exporter AutoLoader); 
  }
  sub new { 
    my $class = shift;
    my @args = @_;
    my $self = Class::MethodMapper->new();
    bless $self, $class;
    my %map = (
      'time_style' => {
        'type'  => 'parameter', 
        'doc'   => 'How recording duration is decided',
        'domain' => 'enum',
        'options' => [qw(track prompt fixed click_stop deadman)],
        'value' => 'prompt',
      },
      'iter_plan' => {
        'type'  => 'volatile',
        'doc'   => 'Currently active plan for iteration: perl code.',
        'value' => 'play; color("yellow"); hold(0.75); color("red"); '
                     . 'record; color;' ,  # see FestVox::ScriptLang 
      },
    );
    $self->set_map(%map);  
    $self->set(@args) if @args;
    $self;
  }
Class::MethodMapper takes a hash of hashes and creates
    get() and set() methods, with (some) validation, for the maps
    listed. Generally, a "parameter" is
    something that can be saved and restored, whereas a
    "volatile" is not serialized at
  save-time. 
  - new(@args)
 
  - Creates and initializes an empty Class::MethodMapper. Calls
      set() with its arguments.
 
 
  - set_map(%map)
 
  - Sets the complete map for this object. See FestVox::InitMap for a good
      example of a method map; it is the big one that FestVox::PointyClicky
      itself uses. This should be generalized to let you set which map,
      as get_map() below.
 
  - get_map($type)
 
  - Get the map of a particular type, e.g.
      "parameter". Note that the object itself
      is the top-level (complete) map, since Class::MethodMapper writes into
      variables in the object of the same name; the 'map' itself is just the
      variables of that "type".
 
  - delete_map(@mapnames)
 
  - Delete the mapping for each variable in
    @mapnames.
 
  - get_meta('type',
    'var')
 
  - Get the "meta" data of a given type for
      a named variable in th method map.
    
    
  type     e.g. 'volatile', 'parameter'
  doc      some human-readable string do describe this
  value    current value; useful for initialization
  domain   e.g. 'enum' or 'ref'
  options  if domain is 'enum', an array reference of allowed values
           if domain is 'ref', 'ARRAY', 'HASH' or the name of a class.
    
   
  - set_meta('type',
    'var', value)
 
  - Just what you would think. Sets the
      "meta" variable
      "type" of
      "var" to
      "value".
 
  - set('var' =>
    'value')
 
  - Set the variable "var" to the value
      'value'. Checks if
      "var" is in the method map, and
      complains if it is not. Does basic type checking if the
      "meta" variable
      "domain" is defined.
    
This means it checks if the value is an element in the array
        reference in "options" if
        "domain" is 'enum' and checks if the
        value is indeed a reference of the specified type if
        "domain" is 'ref' 
   
  - get('var')
 
  - Return the value of 'var' if it is defined and in the method map.
 
  - save('type',
    \&callback, @args)
 
  - loops over all the keys that have type 'type' and calls
    
    
    &$callback ($self, $key, $value, @args);
    
    for each of them, where $key is the
        value of each key and $value is the hashref for
        its value. 
   
  - save_config
    ('filename')
 
  - saves all 'parameter' type key/value pairs to 'filename'
 
  - (\&callback, @args)
 
  - loads earlier saved values of the object keys back by calling
    
    
    &$callback ($self, @args);
    
    it expects the callback to return a ($key,
        $value) list. keeps looping till the callback
        function returns an undefined key. 
   
  - restore_config
    ('filename')
 
  - loads values from the file 'filename', which is in the format that
      save_config writes out.
 
  - var()
 
  - "var" itself is promoted to method
      status; if given no argument, it is considered a
      get(), and if given argument(s), it is considered
      a set(). Thus, if you had a parameter called
      "active" in the method map,
      Class::MethodMapper would use AutoLoader to create a
      active() method (if ever called), so that
      "$self-"active> would return the
      current value, and
      "$self-"active(1)> would set
      it to 1.
 
 
Terribly underdocumented. 
Copyright (c) 2000 Kevin A. Lenzo and Alan W Black, Carnegie
    Mellon Unversity. 
 
 
  Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc.
  |