comp.lang.ada
 help / color / mirror / Atom feed
From: Thom Brooke <tcb_cut_out_80908@yahoo.com>
Subject: Re: Design problem using Multiple Dispatch or Redispatch (long)
Date: 2000/03/15
Date: 2000-03-15T00:00:00+00:00	[thread overview]
Message-ID: <38CEEF82.1DD70BED@yahoo.com> (raw)
In-Reply-To: 38ce8f82@eeyore.callnetuk.com

Nick Roberts wrote:
> 
> First, you define an access-to-procedure type as follows:
> 
>     type Command_Executor is procedure (Command: Root_Command_Type'Class;
>                                             Processor:
> Root_Processor_Type'Class);
> 
> Now - and this is the key bit - you define two types which classify your
> commands and processors:
> 
>     type Command_Category is (...);
>     type Processor_Category is (...);
> 
> And functions that will categorise a command or processor:
> 
>     function Category (Command: in Root_Command_Type) return
> Command_Category;
>     function Category (Processor: in Root_Processor_Type) return
> Processor_Category;
> 
> Now you declare an array which relates categories to executors:
> 
>     Executor: constant array (Command_Category,
>                                         Processor_Category) of
> Command_Executor :=
>         (Elbow_Bending =>
>             Teenagers => Execute_Bend_Elbow_On_Teenager'Access,
>             Twentysomethings =>
> Execute_Bend_Elbow_On_Twentysomething'Access,
>             ...
>             Ancient_Crinklies => null);
>          ...);
> 
> Null access values are used to indicate which kinds of command cannot be
> executed by which kinds of processor. Note how commands and processors can
> be added without necessarily having to change this lookup table (provided
> they fit into existing categories). I've made the array constant, so the
> addition of a new category could prompt substantial recompilation: if this
> might be a problem, you might want to consider using a variable table, with
> some kind of dynamic 'registration' method for populating it.
> 
> --
> Nick Roberts
> http://www.adapower.com/lab/adaos

I was looking at something like this.  Although it was more
Processor-centric,
in that each Processor would define its own Command/Execution
association table.
Command "categorization" would have been more by a
"chain-of-responsibility" pattern.

Unfortunately, each Command really is unique, so each one has distinct
Execute for
each supporting processor.

Thanks.  I'll give this a try.

-- 

-- Thom Brooke
-- Cut out "_CUT_OUT" to get my real email address.




  reply	other threads:[~2000-03-15  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-14  0:00 Design problem using Multiple Dispatch or Redispatch (long) Thom Brooke
2000-03-14  0:00 ` Simon Wright
2000-03-15  0:00   ` Thom Brooke
2000-03-16  0:00     ` Simon Wright
2000-03-14  0:00 ` Nick Roberts
2000-03-15  0:00   ` Thom Brooke [this message]
2000-03-14  0:00 ` tmoran
2000-03-15  0:00   ` Thom Brooke
2000-03-14  0:00 ` David Kristola
2000-03-15  0:00   ` Thom Brooke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox