Week[7] Report: AUTOLOADing OOPs…

July 18, 2008 at 22:20 | Posted in Perl, Summer of Code | Leave a comment

I have been working really intensely on re-writing the code for ModuleTree.pm, in order to be more object-oriented. I have created a new class, ModulePanel, which handles all the UI update functions that ModuleTree Handled. It is the Panel object uder the Modules tab in the main window. With this new scheme, anyone can embed the panel into any Wx-Perl application! So far, there are two Wx::Panel classes for embedding: one for the PODReader (CPANPLUS::Shell::Wx::PODReader::Embed), and one for the modules panel (CPANPLUS::Shell::Wx::ModulePanel). The ModulePanel still needs the MainWindow.xrc file to be loaded. This may change later, but I highly doubt it. If it does, I will create a new xrc file with just the appropriate widgets.

I have used a new Perl construct (new for me, anyway) for ModulePanel: AUTOLOAD. If ModulePanel can’t handle a method, it passes it on to the ModuleTree inside it. I did this to make everything a lot easier: all I have to do for my Frame is change the reference for the ModuleTree to point to the new ModulePanel instead.

My re-write isn’t fully completed yet, as I have come accross a few problems, mainly having to do with a previous change which dealt with limitations of the $cp->module_tree() function (see previous entry). In order to accomodate handling different versions of modules, I have added a _get_mod() method to ModuleTree. It has been a little difficult designing the interface to this function, even though the function itself is quite small. I started writing it this morning, and am still not finished with it. It started as $tree->_get_mod( $module_name|$module_object ), and I went through many incarnations to arrive at (hold your breath):

$tree->_get_mod( $modObject|$name [,{[version=>$version,] [mod=>$modObject,] [getname=>0|1]}])

Here is an explanation of the method:

The first parameter is either the name of a module or a module object. Pretty simple, as we need to know what module we want to deal with.

The optional second parameter is a hash reference to different options. I chose this method keeping in par with the perl style guidelines for functions with multiple parameters. The options are:

  • version: Float. The version number you want, otherwise we use the current version on CPAN.
  • mod: Same as the first parameter. If used, you can omit the first parameter.
  • getname: Boolean. Only return the name of the module. returns $modObject->package_name. If set to 0 or undef, returns the module reference.

Even with these problems, I am going to upload to CVS, so be warned: a lot of crashes may happen if you get this version!

This has been a very trying week, as I thought it would not be so difficult! Instead, I have worked very hard and long, only to feel I have accomplished nothing. But when I really think of all the new ideas I have used and created, I feel like a stronger programmer. I am going to a family reunion this weekend, at White Lake, NC, for some much needed rest and relaxation. Hopefully, It will give me the freshness I need for tackling next week’s (this week’s continuing) problems!


Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: