What does "__PACKAGE__->_factory" actually do?

T

Ted Byers

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top