Branch data Line data Source code
1 : : /* Copyright 2011 Savarese Software Research Corporation
2 : : *
3 : : * Licensed under the Apache License, Version 2.0 (the "License");
4 : : * you may not use this file except in compliance with the License.
5 : : * You may obtain a copy of the License at
6 : : *
7 : : * http://www.savarese.com/software/ApacheLicense-2.0
8 : : *
9 : : * Unless required by applicable law or agreed to in writing, software
10 : : * distributed under the License is distributed on an "AS IS" BASIS,
11 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : * See the License for the specific language governing permissions and
13 : : * limitations under the License.
14 : : */
15 : :
16 : : /**
17 : : * @file
18 : : * This header defines utility functions for making Web service calls,
19 : : * primarily for use by unit tests.
20 : : */
21 : :
22 : : #ifndef __SSRC_WSPR_WS_CALL_UTIL_H
23 : : #define __SSRC_WSPR_WS_CALL_UTIL_H
24 : :
25 : : #include <ssrc/wispers/ws/protocol.h>
26 : : #include <ssrc/wispers/utility/emplace.h>
27 : :
28 : : __BEGIN_NS_SSRC_WSPR_WS
29 : :
30 : : typedef NS_SSRC_WSPR_FCGI::parameter_map::value_type Parameter;
31 : :
32 : : inline Properties *
33 : 2 : get_event(const properties_ptr & template_data, const unsigned int i = 0) {
34 : : property_vector *events =
35 : 2 : template_data->get_ptr<property_vector>("wspr", "event");
36 [ + - + - ]: 2 : return (events != 0 && events->size() > i ? &(*events)[i] : 0);
37 : : }
38 : :
39 : : inline WebServiceProtocol::CallTwoWay::return_type
40 : 1 : call_two_way(WebServiceProtocol::caller_type & call, const string & dest,
41 : : const string & ws_call, const session_ptr & session,
42 : : NS_SSRC_WSPR_FCGI::parameter_map && parameters)
43 : : {
44 : 2 : WebServiceProtocol::CallTwoWay::parameter_type msg(ws_call, parameters, session);
45 [ + - + - : 1 : WebServiceProtocol::CallTwoWay::return_type reply;
+ - ]
46 [ + - ]: 1 : call.call<WebServiceProtocol::CallTwoWay>(dest, &reply, msg);
47 : 1 : return reply;
48 : : }
49 : :
50 : : template<typename... P>
51 : : inline WebServiceProtocol::CallTwoWay::return_type
52 : 1 : call_two_way(WebServiceProtocol::caller_type & call, const string & dest,
53 : : const string & ws_call, const session_ptr & session, P && ...p)
54 : : {
55 [ + - ]: 2 : NS_SSRC_WSPR_FCGI::parameter_map parameters;
56 [ + - + - : 1 : NS_SSRC_WSPR_UTILITY::emplace(parameters, std::forward<P>(p)...);
+ - ]
57 [ + - + - ]: 2 : return call_two_way(call, dest, ws_call, session, std::move(parameters));
58 : : }
59 : :
60 : : __END_NS_SSRC_WSPR_WS
61 : :
62 : : #endif
|