NAME
DTA::CAB::Format::Registry - registry for DTA::CAB I/O formats
SYNOPSIS
use DTA::CAB::Format::Registry;
##========================================================================
## Constructors etc.
$reg = DTA::CAB::Format::Registry->new(%args);
$reg = $reg->clear();
$reg = $reg->refresh();
$reg = $reg->compile(%opts);
\%classReg = $reg->register(%classReg);
##========================================================================
## Methods: Access
\%classReg_or_undef = $reg->lookup(%opts);
$fmt = $reg->newFormat($class_or_short_or_suffix, %opts);
$class_or_undef = $reg->readerClass($class_or_short_or_suffix);
$class_or_undef = $reg->writerClass($class_or_short_or_suffix);
$fmt = $reg->newReader(%opts);
$fmt = $reg->newWriter(%opts);
$readerClass_or_undef = $CLASS_OR_OBJ->fileReaderClass($filename);
$readerClass_or_undef = $CLASS_OR_OBJ->fileWriterClass($filename);
\%classReg_or_undef = $reg->guessFilenameFormat($filename);
\%classReg_or_undef = $reg->short2reg($shortname);
\%classReg_or_undef = $reg->base2reg($basename);
DESCRIPTION
DTA::CAB::Format::Registry provides an object-oriented API for maintainence and easy access to a set of DTA::CAB::Format subclasses.
Constructors etc.
- new
-
$reg = DTA::CAB::Format::Registry->new(%args);
%$obj, %args:
reg => [\%classReg, ...], ##-- registered classes short2reg => {$short=>\%classReg, ...}, ##-- short names to registry entries base2reg => {$base =>\%classReg, ...}, ##-- base names to registry entries
each \%classReg is a HASH-ref of the form:
name => $basename, ##-- basename for the class (package name) short => $shortname, ##-- short name for the class (default = package name suffix, lower-cased) readerClass => $readerClass, ##-- default: $base ##-- NYI writerClass => $writerClass, ##-- default: $base ##-- NYI filenameRegex => $regex, ##-- filename regex for guessFilename()
See also "register".
- refresh
-
$reg = $reg->clear();
Clears the registry.
- refresh
-
$reg = $reg->refresh();
Re-registers all formats in $reg->{reg}.
- compile
-
$reg = $reg->compile(%opts);
Adds the following keys to each registry item \%classReg:
reader => $readerObj, ##-- = $classReg{readerClass}->new(%opts) writer => $writerObj, ##-- = $classReg{writerClass}->new(%opts)
- register
-
\%classReg = $reg->register(%classReg);
%classReg:
name => $basename, ##-- basename for the class (package name): REQUIRED short => $shortname, ##-- short name for the class (default = package name suffix, lower-cased) readerClass => $readerClass, ##-- default: $base ##-- NYI writerClass => $writerClass, ##-- default: $base ##-- NYI filenameRegex => $regex, ##-- filename regex for guessFilenameFormat()
Methods: Access
- lookup
-
\%classReg_or_undef = $reg->lookup(%opts);
Get the most recently registered entry for %opts, which may contain (in order of decreasing priority):
class => $class, ##-- short name, basename, or "DTA::CAB::Format::" suffix file => $filename, ##-- attempt to guess format from $filename
- newFormat
-
$fmt = $reg->newFormat($class_or_short_or_suffix, %opts);
Creates a new format of the registered base class matching $class_or_short_or_suffix; backwards-compatible.
- readerClass
-
$class_or_undef = $reg->readerClass($class_or_short_or_suffix);
Get registered reader class for $class_or_short_or_suffix
- writerClass
-
$class_or_undef = $reg->writerClass($class_or_short_or_suffix);
Get registered writer class for $class_or_short_or_suffix
- newReader
-
$fmt = $reg->newReader(%opts);
Create and return a new reader object. %opts may contain any %lookup options (class,file), and are otherwise passed to READERCLASS->new()
- newWriter
-
$fmt = $reg->newWriter(%opts);
Create and return a new writer object. %opts may contain any %lookup options (class,file), and are otherwise passed to WRITERCLASS->new().
- fileReaderClass
-
$readerClass_or_undef = $CLASS_OR_OBJ->fileReaderClass($filename);
Backkwards-compatible wrapper for lookup(); attempts to guess reader class name from $filename.
- fileWriterClass
-
$readerClass_or_undef = $CLASS_OR_OBJ->fileWriterClass($filename);
Backwards-compatible wrapper for lookup(); attempts to guess writer class name from $filename.
- guessFilenameFormat
-
\%classReg_or_undef = $reg->guessFilenameFormat($filename);
Backwards-compatible wrapper for $reg->lookup(file=>$filename).
- short2reg
-
\%classReg_or_undef = $reg->short2reg($shortname);
Gets registry entry for short name $shortname.
- base2reg
-
\%classReg_or_undef = $reg->base2reg($basename);
Gets registry entry for class basename $basename.
AUTHOR
Bryan Jurish <moocow@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2011-2019 by Bryan Jurish
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.
SEE ALSO
dta-cab-convert.perl(1), DTA::CAB::Format(3pm), DTA::CAB(3pm), perl(1), ...