Search code examples
c++annotationsauto-generate

Is there a good way, to generate code in C++ for sending function parameters over the network?


I need something (like annotations, reflections, defines, or something completely different) that I can add to a arbitrary function or function call.

For every function f, which has this something added, a specific function t should be invoked with the parameters of f.

The function t should now send its parameters over the network to a other program.

Is there a way to do something like this?


Solution

  • The general principle behind this is called marshalling, where the parameteres of a function are wrapped up in a way that you can send them to some other computer. The sender marshalls the parameters, the receiver unmarshalls. Both need to have an understanding on the types, and must do it in a way consistent with the different computer architectures.

    Remote procedure calls (RPC) are one way of sending function calls from one computer to another, and need some marshalling behind them.

    XMLRPC, as pointed out by Victor, is one way to do it, where the marshalling happens via XML. There are lots of other packages, and googling for RPCs and marshalling should give more possibilities, but XMLRPC might be just what you want.

    CORBA and DCOM are related mechanism. The idea of sending function calls between computers is one major concept in distributed systems, so maybe look a round a little more, probably there are very simple solutions to your specific problem.