need a dispatch table and tried it this way:

class Action {
    string[string] function(string[string] p) action;
    this( string[string] function(string[string] p) action_ref ) {
        this.action = action_ref;
    }
    string[string] execute(string[string] parameters) {
        return this.action(parameters);
    }
}

then

Action[string] dispatch_table = [
    "test1" : new Action(&myapp.index.test),
    "test2" : new Action(&myapp.index.another_test)
];

auto my_first_result = dispatch_table["test1"].execute(["a": "aa", "b":"BB"]); auto my_second_result = dispatch_table["test2"].execute([" some string key for test2": "in test 2"]);

This works, but I am wondering if there is another way. Does D support symbolic references so I could keep the hashtable in a string[string], or even use a string variable holding a class name to instantiate a class ?

thank you

Reply via email to