Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Oberstein committed Mar 25, 2014
1 parent ef8c197 commit 97a11df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
41 changes: 22 additions & 19 deletions include/autobahn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ namespace autobahn {
*/
boost::future<boost::any> call(const std::string& procedure, const anyvec& args);


/**
* Calls a remote procedure. Typed positional arguments, generic return.
*/
Expand All @@ -100,21 +99,6 @@ namespace autobahn {
return _call_1(procedure, accumulated, args...);
}

/// Entry point into template recursion for typed argument accumulation.
template <typename Arg, typename... Args>
boost::future<boost::any> _call_1(const std::string& procedure, anyvec& accumulated, const Arg& arg, const Args&... args) {
accumulated.push_back(arg);
return _call_1(procedure, accumulated, args...);
}

/// Terminal of template recursion for typed argument accumulation.
template <typename Arg>
boost::future<boost::any> _call_1(const std::string& procedure, anyvec& accumulated, const Arg& arg) {
accumulated.push_back(arg);
return call(procedure, accumulated);
}


/**
* Calls a remote procedure. Generic positional argument vector, typed return.
*/
Expand All @@ -125,26 +109,45 @@ namespace autobahn {
});
}

/// Entry point into template recursion for typed argument accumulation.
/**
* Calls a remote procedure. Typed positional arguments, typed return.
*/
template <typename T, typename... Args>
boost::future<T> call(const std::string& procedure, const Args&... args) {
boost::future<T> call_static(const std::string& procedure, const Args&... args) {
anyvec accumulated;
return _call_2<T>(procedure, accumulated, args...);
}

private:

/// Entry point into template recursion for typed argument accumulation, generic return.
template <typename Arg, typename... Args>
boost::future<boost::any> _call_1(const std::string& procedure, anyvec& accumulated, const Arg& arg, const Args&... args) {
accumulated.push_back(arg);
return _call_1(procedure, accumulated, args...);
}

/// Terminal of template recursion for typed argument accumulation, generic return.
template <typename Arg>
boost::future<boost::any> _call_1(const std::string& procedure, anyvec& accumulated, const Arg& arg) {
accumulated.push_back(arg);
return call(procedure, accumulated);
}

/// Entry point into template recursion for typed argument accumulation, typed return.
template <typename T, typename Arg, typename... Args>
boost::future<T> _call_2(const std::string& procedure, anyvec& accumulated, const Arg& arg, const Args&... args) {
accumulated.push_back(arg);
return _call_2<T>(procedure, accumulated, args...);
}

/// Terminal of template recursion for typed argument accumulation, typed return.
template <typename T, typename Arg>
boost::future<T> _call_2(const std::string& procedure, anyvec& accumulated, const Arg& arg) {
accumulated.push_back(arg);
return call<T>(procedure, accumulated);
}

private:

void process_welcome(wamp_msg_t& msg);

Expand Down
4 changes: 2 additions & 2 deletions test/test7d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main () {

// Launch policy to use
//
//boost::launch lp = boost::launch::deferred;
boost::launch lp = boost::launch::deferred;

// To establish a session, we join a "realm" ..
//
Expand All @@ -49,7 +49,7 @@ int main () {

// call a remote procedure ..
//
session.call<int>("com.mathservice.add2", 23, 777).then([](boost::future<int> f) {
session.call_static<int>("com.mathservice.add2", 23, 777).then(lp, [](boost::future<int> f) {

// call result received
//
Expand Down

0 comments on commit 97a11df

Please sign in to comment.