<?xml version="1.0" encoding="windows-1252"?>
<node id="180974" title="Re: ?Re: RFC: Class::DispatchToAll" created="2002-07-11 04:19:27" updated="2004-09-25 16:13:46">
<type id="11">
note</type>
<author id="101964">
domm</author>
<data>
<field name="doctext">
&lt;b&gt;My Problem:&lt;/b&gt;

I've got several classes, looking a little bit like this:

&lt;pre&gt;
                     App
                      |
                  App::Basic
                 /         \
App::Basic::Special1     App::Basic::Special2 
     |                        |
     |                        |
     |            My::App     |
     |           /       \    |
My::App::Special1         My::App::Special2
&lt;/pre&gt;


Note that My::App &lt;b&gt;doesn't&lt;/b&gt; inherit from App. And note that there are My::OtherApp, Your::App too, looking like My::App and inheriting from App::*
&lt;p&gt;
Each of this Classes contains some config values as Class Data.
&lt;p&gt;
I want to be able to fetch all those config values, merge them and do something with the result.
&lt;p&gt;
E.g.: Say, each class contains an array called @order and a hash called %lables.&lt;br&gt;
@order contains some fields to be displayed&lt;br&gt;
%lables contains the name of those fields as keys and a "human readable" name as values.&lt;br&gt;
&lt;code&gt;
@order=(field1,field2,field2,..);
%lable={
         field1=&amp;gt;"Name of Field 1",
         field2=&amp;gt;"Name of Field 2",
..
);
&lt;/code&gt;
&lt;p&gt;
Each Class now defines some of those values. Some Classes append new values to @order and %lables, some overwrite data in %lables.
&lt;p&gt;
There are some basic fields (used everywhere in the app) defined in App::Basic. Each App::Basic::Special1/2 adds some fields unique to this special case.
&lt;p&gt;
Now, My::App changes some field lables (e.g. use another language). My::App::Special1 may add even more fields that are only needed in My::App (there might be a My::OtherApp::Special1 that inherits from App::Basic::Special1 and doesn't use this fields)
&lt;p&gt;
Then I call dispatch_to_all('get_fields') which fetches all those @field arrays, massage the returned array of all return values to fit my needs, and voila: I get the array of fields used by this Class, without having to specify the "Basic" fields in all Subclasses (which would result in a lot of typing and and even bigger lot of problems should I need to change a App::Basic config value)
&lt;p&gt;
This was/is my problem, and that's why I wrote Class::DispatchToAll, which seems the best way to solve this problem to me. But if you now another way, please let me know...


&lt;code&gt;
--
#!/usr/bin/perl
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&amp;&amp;print$_.$/}
&lt;/code&gt;</field>
<field name="root_node">
180852</field>
<field name="parent_node">
180906</field>
</data>
</node>
