What does "__PACKAGE__->_factory" actually do?

Discussion in 'Perl Misc' started by Ted Byers, May 13, 2012.

  1. Ted Byers

    Ted Byers Guest

    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
    Ted Byers, May 13, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    486
    Oliver
    Nov 13, 2003
  2. =?Utf-8?B?Y2hyaXN2Yw==?=

    thread.start() does not actually execute the assigned method

    =?Utf-8?B?Y2hyaXN2Yw==?=, Apr 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,248
    davidallen
    Jun 10, 2007
  3. Alek Nazarian
    Replies:
    7
    Views:
    3,223
    Alek Nazarian
    Oct 22, 2003
  4. Replies:
    3
    Views:
    4,220
    John McGrath
    May 26, 2005
  5. Karl
    Replies:
    3
    Views:
    352
Loading...

Share This Page