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
SimpleSendObjectRequest.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 SIMPLE_SEND_OBJECT_REQUEST_H
20 #define SIMPLE_SEND_OBJECT_REQUEST_H
21 
22 #include "PDBLogger.h"
23 
24 // This templated function makes it easy to write a simple network client that asks a request,
25 // as a PDB object, then sends some data (as a Handle <pdb :: Vector <DataType>>) to a server and
26 // then gets a result.
27 //
28 // The type args are:
29 // RequestType: the type of object to create to send over the wire
30 // DataType: the type of data to send in an object
31 // ResponseType: the type of object we expect to receive over the wire
32 // ReturnType: the type we will return to the caller
33 // RequestTypeParams: type of the params to use for the contructor to the object we send over the
34 //wre
35 //
36 // The params are:
37 // myLogger: The logger we write error messages to
38 // port: the port to send the request to
39 // address: the address to send the request to
40 // onErr: the value to return if there is an error sending/receiving data
41 // bytesForRequest: the number of bytes to give to the allocator used to build the request
42 // processResponse: the function used to process the response to the request
43 // args: the arguments to give to the constructor of the request
44 //
45 
46 namespace pdb {
47 
48 template <class RequestType,
49  class DataType,
50  class ResponseType,
51  class ReturnType,
52  class... RequestTypeParams>
53 ReturnType simpleSendObjectRequest(PDBLoggerPtr myLogger,
54  int port,
55  std::string address,
56  ReturnType onErr,
57  size_t bytesForRequest,
58  function<ReturnType(Handle<ResponseType>)> processResponse,
59  DataType dataToSend,
60  RequestTypeParams&&... args);
61 }
62 
63 #endif
64 
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
ReturnType simpleSendObjectRequest(PDBLoggerPtr myLogger, int port, std::string address, ReturnType onErr, size_t bytesForRequest, function< ReturnType(Handle< ResponseType >)> processResponse, DataType dataToSend, RequestTypeParams &&...args)