Solved

Call a function from a group of different argument lists with out switch statement

Posted on 2002-04-10
5
166 Views
Last Modified: 2010-04-02
Here I am having three lists

1)Pointer to Functions (Functions are of variable arguments and different argument types)
2)Argument Type List
3)Arguments received( Received in a buffer, In this we are not receiving any argument type. It is a block of data)

From this I need initialize the arguments and assing the data received in 3 and call the function with these initialized argumnets.
One way is switch case depends on function type.
This will consume lot of memory.

Another way is push the received data onto the stack depends on the srgument type and call the function(This nneds assemly language and not user friendly).
If any other Idea..Please ....

Thanks in advance,
klkreddy
0
Comment
Question by:klkreddy
5 Comments
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6933010
If you're trying to implement RPC I'd suggest first looking into existinggmechanisms. RPC isn't trivial.
0
 

Author Comment

by:klkreddy
ID: 6934338
I want to implement the RPC with out XDR.So I am struggling this much.
0
 
LVL 22

Accepted Solution

by:
ambience earned 200 total points
ID: 6941130
not sure though what exactly the situation is but ..

how about calling the function by pointers indexed by function type.

like say g_func is an array of pointer to functions.

so instead of a switch you index into the array using the function type or id.

(g_func[ function_tpe ])(args...);

this doesnt require assembly to manipulate stack too. Provided you have function ids for all the function callable.

Please post further information incase i havent understood the problem.
0
 
LVL 11

Expert Comment

by:griessh
ID: 7012034
Dear klkreddy

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "ambience"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Author Comment

by:klkreddy
ID: 7015530
Hi Ambience,
          Thanks for suggesting me the suitable answer.
Regards,
klkreddy
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now