Loading ...
Sorry, an error occurred while loading the content.

275Re: 'maps' and 'delegates' in IO::ClassLoader.pm ??

Expand Messages
  • robnagler
    May 23, 2005
      --- In extremeperl@yahoogroups.com, "ingo_1972" <ingox@g...> wrote:
      > What are maps and delegates doing here?
      > $cfg is a empty HASH. But where is maps coming from ?

      These are configuration parameters. Bivio::IO::ClassLoader offers
      three services: simple imports, mapped imports, and delegated
      imports. The header documentation explains the three ways you can
      import:

      C<Bivio::IO::ClassLoader> implements dynamic class loading.
      L<simple_require|"simple_require"> implements a dynamic C<use> clause.

      L<map_require|"map_require"> is an indirect load via mapped name.
      The classes
      loaded have names of the form I<Map>.I<Class>. The I<map> is a
      simple perl
      identifier which identifies a class path or handler class which does the
      loading. map_require calls simple_require if the I<map_class> is a
      simple class.

      L<delegate_require|"delegate_require"> is called by classes which
      delegate
      (part of) their implementations. A I<delegate> may provide I<info>,
      a data
      structure which defines the internals of, say, a
      L<Bivio::Type::Enum|Bivio::Type::Enum>. A delegate may also completely
      implement the class.

      B<NOTE: You can only load classes which are of type
      L<Bivio::UNIVERSAL|Bivio::UNIVERSAL> with this module.>

      This last point is important. If you just need a simple class loader,
      you probably don't want Bivio::IO::ClassLoader. Use something
      simpler, e.g.

      eval 'use My::Class;1' || die($@);

      There are probably CPAN packages which do that much.

      ClassLoader is mostly used by bOP to manage multiple applications
      which may override standard classes (such as ECService or
      UserCreateForm). ClassLoader is also used defer loading classes until
      they are needed. The latter case is a performance optimization for
      command line utilities.

      Rob
    • Show all 6 messages in this topic