A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CompositeRequest.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 #ifndef COMPOSITE_REQUEST_H
20 #define COMPOSITE_REQUEST_H
21 
22 #include "PDBLogger.h"
23 #include "PDBCommunicator.h"
24 
25 // This templated function makes it easy to write a simple network client that asks a request,
26 // then gets a result. See, for example, CatalogClient.cc for an example of how to use.
27 //
28 // The type args are:
29 // RequestType: the type of object to create to send over the wire
30 // ResponseType: the type of object we expect to receive over the wire
31 // ReturnType: the type we will return to the caller
32 // RequestTypeParams: type of the params to use for the contructor to the object we send over the
33 //wre
34 //
35 // The params are:
36 // myLogger: The logger we write error messages to
37 // port: the port to send the request to
38 // address: the address to send the request to
39 // onErr: the value to return if there is an error sending/receiving data
40 // bytesForRequest: the number of bytes to give to the allocator used to build the request
41 // processResponse: the function used to process the response to the request
42 // args: the arguments to give to the constructor of the request
43 //
44 
45 namespace pdb {
46 
47 template <class RequestType, class ResponseType, class ReturnType, class... RequestTypeParams>
48 ReturnType compositeRequest(
49  PDBLoggerPtr myLogger,
50  int port,
51  std::string address,
52  ReturnType onErr,
53  size_t bytesForRequest,
54  function<ReturnType(Handle<ResponseType>, PDBCommunicator)> processResponse,
55  RequestTypeParams&&... args);
56 }
57 
58 #endif
59 
60 #include "CompositeRequest.cc"
ReturnType compositeRequest(PDBLoggerPtr myLogger, int port, std::string address, ReturnType onErr, size_t bytesForRequest, function< ReturnType(Handle< ResponseType >, PDBCommunicator)> processResponse, RequestTypeParams &&...args)
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40