Questions tagged [dispatch-table]

In computer science, a dispatch table is a table of pointers to functions or methods. Use of such a table is a common technique when implementing late binding in object-oriented programming.

In computer science, a dispatch table is a table of pointers to functions or methods. Use of such a table is a common technique when implementing late binding in object-oriented programming.

22 questions
6
votes
7 answers

How do I implement dispatch tables in Perl?

I need to write a storage related app in Perl. The app needs to upload files from the local machine to some other storage nodes. Currently, the uploading method is FTP, but in the future it may be bittorrent or some unknown super-file-transferring…
Haiyuan Zhang
5
votes
1 answer

How to pass parameters in a Python Dispatch Table

I am trying to construct a dispatch the following way: def run_nn(type=None): print type, 'nn' return def run_svm(type=None): print type, 'svm' return action = {'nn' : run_nn( type=None), 'svm' : run_svm(type=None),} I…
neversaint
  • 60,904
  • 137
  • 310
  • 477
4
votes
3 answers

How do I implement a dispatch table for a text adventure game?

I am making a text adventure in C#, and someone suggested that I use a dispatch table instead of a switch statement. Here's the switch statement code: #region Public Methods public static void Do(string aString) { …
rshea0
  • 11,769
  • 9
  • 27
  • 40
3
votes
3 answers

Implementing a Dispatch Table in Objective-C: how to declare an array of selectors

I'm trying to implement a dispatch table, so that I can call a selector with the following example code: NSInteger i = 2; [myObject performSelector:selectors[i]]; I'm trying to store user preferences which affect which method of an API gets called.…
Moshe
  • 57,511
  • 78
  • 272
  • 425
3
votes
1 answer

What is a dispatch table? How can I implement it in C?

Let me start by saying that I know how function pointers work. If you would like to explain them in more detail please go ahead, however what I ask from you is how can I implement them in a dispatch table using C. I have searched for what a…
HamzaKerem
  • 121
  • 1
  • 8
3
votes
1 answer

Create dispatch table registering functions across multiple source files in C

How can I implement a dynamic dispatch table in C It's essentially the same question as the linked issue, so ... As your Strategy.c obviously already knows about the strategy instances by name (#include "XYstrategy.h") you could go the whole …
3
votes
3 answers

Where are Objective-C selectors registered/stored?

I don't quite get the Objective-C selectors. The problem is: Where are Objective-C selectors stored ? How do Objective-C Compiler and Runtime System work, so that they convert the method names into SEL ?
denis631
  • 1,765
  • 3
  • 17
  • 38
3
votes
4 answers

Dispatch Table in C++

Suppose I have something like the following: class Point : geometry { ... Point(double x, double y) { } double distanceTo(Line) { } double distanceTo(Point) { } } class Line : geometry { ... Line(double x, double y, double…
adk
  • 4,479
  • 9
  • 36
  • 38
2
votes
1 answer

When might a dispatch table be as good as method_missing in Ruby?

Are there any situations where a dispatch table, implemented as a hash of lambdas, might be as good, if not better, than over-riding Ruby's method_missing? I'm asking because I used this technique today as I'm a comparative newbie with Ruby, but…
Dexygen
  • 12,287
  • 13
  • 80
  • 147
2
votes
1 answer

How to view the virtual function table of an inherited Java class

I have the following java code: class Father { public void walk(int x) { System.out.format("Fwalk %d", x); } public void run (int x) { System.out.format("Frun %d", x); } public void swim(int x) { System.out.format("Fswim %d", x);…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
2
votes
1 answer

How to initialize at runtime a list with all the static classes of an artifact to be able to dynamically call their methods with their parameters?

I have the following problem: I need to test a list of algorithms (~300) with maximum speed performance. Since every one is unique, I create them as static classes and made a execute() function like bellow. Each one does have some fixed parameters…
yo3hcv
  • 1,531
  • 2
  • 17
  • 27
2
votes
3 answers

Perl: Need assistance converting if-elsif-else to something simpler

I've been reading up on dispatch tables and I get the general idea of how they work, but I'm having some trouble taking what I see online and applying the concept to some code I originally wrote as an ugly mess of if-elsif-else statements. I have…
Speeddymon
  • 496
  • 2
  • 20
2
votes
2 answers

How do I create a dispatch table within a class in PHP?

Say I have a class with a private dispatch table. $this->dispatch = array( 1 => $this->someFunction, 2 => $this->anotherFunction ); If I then call $this->dispatch[1](); I get an error that the method is not a string. When I make it a…
mk.
  • 26,076
  • 13
  • 38
  • 41
2
votes
2 answers

How can I use dispatch tables in Perl?

Possible Duplicate: How do I implement dispatch tables in Perl? I have a hash table that contains commands such as int(rand()) etc. How do I execute those commands?
Chaggster
  • 2,441
  • 3
  • 21
  • 14
1
vote
1 answer

Where to place a dispatch table in MVC?

A dispatch table (or dispatch method) is both a table (model) and a router/controller. Imagine a tabbed navigation where there may be 30 tabs for various end users. Each tab is essentially a page that has its own controller and views. In my case, a…
vol7ron
  • 40,809
  • 21
  • 119
  • 172
1
2