What does "__PACKAGE__->_factory" actually do?



Here is a class created by wsdl2perl.pl, most of which I understand (I'll interject comments representing my understanding and end with the questions):

# obviously I haven't quoted the whol file, but rather the key components
# these I understand as private data members of the class, wth some
# syntactic sugar (ATTR) provided by the class package to automagically make
# the read accessor function (very nice)
my %id_of :ATTR(:get<id>);
my %type_of :ATTR(:get<type>);
my %name_of :ATTR(:get<name>);
my %size_of :ATTR(:get<size>);
my %extension_of :ATTR(:get<extension>);
my %file_of :ATTR(:get<file>);

# I can't find the documentation for this function
# I know wha a factory is in OOP, having written enough of them in C++, but
# I can't find the documentation for this function, and I am especially
# interested in knowing what the arguments are supposed to be and how they're
# used.
# obviously the first appears to be an array reference to an array with field
# names, and the second two are hashes mapping the field names to hashes and
# their types
__PACKAGE__->_factory(
[ qw( id
type
name
size
extension
file

) ],
{
'id' => \%id_of,
'type' => \%type_of,
'name' => \%name_of,
'size' => \%size_of,
'extension' => \%extension_of,
'file' => \%file_of,
},
{
'id' => 'SOAP::WSDL::XSD::Typelib::Builtin::int',
'type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
'name' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
'size' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
'extension' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
'file' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
},
{

'id' => 'id',
'type' => 'type',
'name' => 'name',
'size' => 'size',
'extension' => 'extension',
'file' => 'file',
}
);

But, this is confusing as it looks like the data members are supposed to be either an integer or a string (i.e. look at the SOAP types), but why, then, are the data members for this class defined as hashes?

Clarification would be helpful.

Thanks

Ted
.



Relevant Pages

  • Re: Problem with hash and regexp
    ... > documenting the correspondence between keys and values in hashes, ... > those more knowledgable about perl internals than I. ... It may be a bug in the documentation, but I don't see how it ...
    (comp.lang.perl.misc)
  • Re: Problem with hash and regexp
    ... > seem to belie the Comma Operator documentation in perldoc perlop: ... > documenting the correspondence between keys and values in hashes, ...
    (comp.lang.perl.misc)
  • Re: Newbea question again?
    ... > def check h, key ... > If your hashes are not nested (i.e. you have one level that you are ... After looking at the documentation, I guess you can simply replace... ...
    (comp.lang.ruby)