Commit f4ae990e authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Syncing up work with branch that uses cpprestsdk


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 208297bf
......@@ -72,16 +72,38 @@ ExternalProject_Add(cppmicroservices
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
)
ExternalProject_Add(restclient-cpp
set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
if(APPLE AND NOT OPENSSL_ROOT_DIR)
if (EXISTS /usr/local/opt/openssl)
message(STATUS "${BoldGreen}[OSX] Searching for OpenSSL from /usr/local/opt/openssl. Override with -DOPENSSL_ROOT_DIR=...${ColorReset}")
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()
elseif(EXISTS /etc/redhat-release AND NOT OPENSSL_ROOT_DIR)
# we are on fedora... check for custom openssl install
# in /usr/local/ssl
if (EXISTS /usr/local/ssl)
message(STATUS "${BoldGreen}[Fedora] Searching for OpenSSL from /usr/local/ssl. Override with -DOPENSSL_ROOT_DIR=...${ColorReset}")
set(OPENSSL_ROOT_DIR /usr/local/ssl)
endif()
endif()
find_package(OpenSSL 1.0.2 REQUIRED)
message(STATUS "${BoldGreen}Found OpenSSL version ${OPENSSL_VERSION}${ColorReset} at ${OPENSSL_ROOT_DIR}")
ExternalProject_Add(cpprestsdk
DEPENDS cppmicroservices
GIT_REPOSITORY https://github.com/mrtazz/restclient-cpp
GIT_REPOSITORY https://github.com/Microsoft/cpprestsdk
GIT_TAG master
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND sh autogen.sh && sh ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} --prefix=${CMAKE_INSTALL_PREFIX}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../cpprestsdk/Release/ -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DBUILD_TESTS=OFF
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
)
set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(CppRSDK_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(CppRSDK_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
......@@ -93,37 +115,26 @@ if (OPENMP_FOUND)
endif()
ExternalProject_Add(xacc-core
DEPENDS cppmicroservices restclient-cpp
DEPENDS cppmicroservices cpprestsdk
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xacc
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DBOOST_ROOT=${BOOST_ROOT}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
#-DXACC_HAS_PYTHON=${PYTHONLIBS_FOUND}
-DXACC_PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
-DXACC_PYTHON_LIBRARIES=${PYTHON_LIBRARIES}
-DPYBIND11_DIR=${CMAKE_SOURCE_DIR}/python/pybind11
# -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
# -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
# -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
# -DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
-DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/stage
TEST_BEFORE_INSTALL 1
)
#set(XACC_BASE_DIR ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
#set(XACC_INCLUDE_DIR ${XACC_BASE_DIR}/include/xacc)
#set(XACC_LIBRARY_DIR ${XACC_BASE_DIR}/lib)
#string (REPLACE ";" " " XACC_Boost_LIBRARIES "${Boost_LIBRARIES}")
#string (REPLACE ";" " " XACC_MPI_INCLUDE_PATHS "${MPI_CXX_INCLUDE_PATH}")
ExternalProject_Add(xacc-quantum
DEPENDS xacc-core
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/quantum
......@@ -131,25 +142,23 @@ ExternalProject_Add(xacc-quantum
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DBOOST_ROOT=${BOOST_ROOT}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DBOOST_ROOT=${BOOST_ROOT}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib
# -DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
# -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
# -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
# -DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
-DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
TEST_AFTER_INSTALL 1
)
#find_package(PythonLibs)
#if(PYTHONLIBS_FOUND)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXACC_HAS_PYTHON")
if (PYTHON_INCLUDE_DIR)
ExternalProject_Add(xacc-python
DEPENDS xacc-core xacc-quantum
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python
......@@ -157,21 +166,21 @@ ExternalProject_Add(xacc-python
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DBOOST_ROOT=${BOOST_ROOT}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DBOOST_ROOT=${BOOST_ROOT}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include #${XACC_INCLUDE_DIR}
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DFROM_SETUP_PY=${FROM_SETUP_PY}
-DXACC_PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include #${XACC_INCLUDE_DIR}
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DFROM_SETUP_PY=${FROM_SETUP_PY}
-DXACC_PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
TEST_AFTER_INSTALL 1
)
#endif()
endif()
# Install the config file for external projects to use
# This is cool, users just add find_package(XACC REQUIRED) to
......
......@@ -13,4 +13,4 @@ set (XACC_INCLUDE_DIRS "${XACC_ROOT}/include/cppmicroservices3;${XACC_ROOT}/incl
set (XACC_LIBRARY_DIR "${XACC_ROOT}/lib")
set(CppUsLib CppMicroServicesd)
link_directories("${XACC_ROOT}/lib")
set (XACC_LIBRARIES "xacc;CppMicroServices;restclient-cpp")
set (XACC_LIBRARIES "xacc;CppMicroServices;cpprest;@OPENSSL_LIBRARIES@")
......@@ -48,7 +48,7 @@ link_directories(${Boost_LIBRARY_DIR})
#if (NOT cppus_has_d_suffix)
# set(CppUsLib CppMicroServices)
#endif()
target_link_libraries(pyxacc xacc xacc-quantum-gate xacc-quantum-aqc CppMicroServices ${Boost_LIBRARIES} restclient-cpp) #cpprest ${OPENSSL_LIBRARIES})
target_link_libraries(pyxacc xacc xacc-quantum-gate xacc-quantum-aqc CppMicroServices ${Boost_LIBRARIES} cpprest ${OPENSSL_LIBRARIES})
if (APPLE)
add_custom_command(TARGET pyxacc
......
......@@ -60,13 +60,13 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices)
endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} xacc restclient-cpp) #cpprest ${OPENSSL_LIBRARIES})
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} xacc cpprest ${OPENSSL_LIBRARIES})
if (APPLE)
add_custom_command(TARGET xacc-quantum-aqc
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:xacc-quantum-aqc>)
endif()
#if (APPLE)
#add_custom_command(TARGET xacc-quantum-aqc
# POST_BUILD COMMAND
# ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:xacc-quantum-aqc>)
#endif()
add_subdirectory(ir)
add_subdirectory(compiler)
......
......@@ -12,5 +12,5 @@
# *******************************************************************************/
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};dl;pthread;xacc-quantum-aqc;xacc;restclient-cpp")#rest;${OPENSSL_LIBRARIES}")
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};dl;pthread;xacc-quantum-aqc;xacc;cpprest;${OPENSSL_LIBRARIES}")
......@@ -12,5 +12,5 @@
# *******************************************************************************/
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;restclient-cpp")#rest;${OPENSSL_LIBRARIES}")
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;cpprest;${OPENSSL_LIBRARIES}")
......@@ -64,13 +64,13 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices)
endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} xacc ${CppUsLib} restclient-cpp) #cpprest ${OPENSSL_LIBRARIES})
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} xacc ${CppUsLib} cpprest ${OPENSSL_LIBRARIES})
if (APPLE)
add_custom_command(TARGET xacc-quantum-gate
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:xacc-quantum-gate>)
endif()
#if (APPLE)
#add_custom_command(TARGET xacc-quantum-gate
# POST_BUILD COMMAND
# ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:xacc-quantum-gate>)
#endif()
add_subdirectory(compiler)
add_subdirectory(ir)
......
......@@ -12,5 +12,5 @@
# *******************************************************************************/
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc;restclient-cpp")#rest;${OPENSSL_LIBRARIES}")
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc;cpprest;${OPENSSL_LIBRARIES}")
......@@ -13,5 +13,5 @@
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};xacc;xacc-quantum-gate;restclient-cpp")#rest;${OPENSSL_LIBRARIES}")
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};xacc;xacc-quantum-gate;cpprest;${OPENSSL_LIBRARIES}")
......@@ -14,6 +14,6 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;xacc-quantum-gate;restclient-cpp")#rest;${OPENSSL_LIBRARIES}")
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;xacc-quantum-gate;cpprest;${OPENSSL_LIBRARIES}")
......@@ -21,9 +21,7 @@ message(STATUS "C++ version ${CXX_STANDARD} configured.")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules")
include(tests)
# We require Boost without MPI
find_package(Boost COMPONENTS system program_options regex filesystem chrono graph REQUIRED)
#endif()
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${XACC_ROOT}/tpls/spdlog)
......@@ -38,28 +36,16 @@ include_directories("${CMAKE_SOURCE_DIR}/accelerator")
include_directories("${CMAKE_SOURCE_DIR}/utils")
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${CMAKE_BINARY_DIR})
#include_directories(${PYBIND11_DIR}/include)
#find_package(PythonLibs REQUIRED)
#include_directories(${XACC_PYTHON_INCLUDE_DIR})
# Create a xacc config header file
configure_file("${XACC_ROOT}/cmake/xacc_config.hpp.in" "${CMAKE_BINARY_DIR}/xacc_config.hpp")
install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc)
#set (PACKAGE_NAME "XACC Specification")
#set (PACKAGE_DESCIPTION "The XACC Programming Framework")
set (LIBRARY_NAME xacc)
file (GLOB HEADERS XACC.hpp ir/*.hpp program/*.hpp compiler/*.hpp accelerator/*.hpp accelerator/remote/*.hpp utils/*.hpp)
file (GLOB SRC *.cpp program/*.cpp utils/*.cpp accelerator/remote/*.cpp)
#find_package(PythonLibs)
#if(PythonLibs_FOUND)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXACC_HAS_PYTHON")
# include_directories(${XACC_ROOT}/tpls/pybind11/include)
# include_directories(${XACC_PYTHON_INCLUDE_DIR})
#endif()
set(CppUsLib CppMicroServicesd)
link_directories(${CPPUS_LIBRARY_DIR})
......@@ -72,14 +58,12 @@ if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices)
endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} restclient-cpp)
if (APPLE)
add_custom_command(TARGET xacc
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:xacc>)
set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};${OPENSSL_CRYPTO_LIBRARY}")
endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} ${OPENSSL_LIBRARIES} cpprest)
# Get the test files
file(GLOB test_files utils/tests/*Tester.cpp accelerator/tests/*Tester.cpp)
......
......@@ -13,37 +13,57 @@
#include "RemoteAccelerator.hpp"
namespace xacc {
const std::string Client::post(const std::string& remoteUrl,
const std::string RestClient::post(const std::string& remoteUrl,
const std::string& path, const std::string& postStr,
std::map<std::string, std::string> headers) {
using namespace RestClient;
init();
Connection* conn = new Connection(remoteUrl);
HeaderFields _headers;
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
headers.insert(std::make_pair("Accept", "*/*"));
}
http::uri uri = http::uri(remoteUrl);
http_client_config config;
config.set_validate_certificates(false);
http_client postClient(
http::uri_builder(uri).append_path(U(path)).to_uri(), config);
http_request postRequest(methods::POST);
for (auto& kv : headers) {
_headers[kv.first] = kv.second;
postRequest.headers().add(kv.first, kv.second);
}
conn->SetHeaders(headers);
Response r = conn->post(path, postStr);
if (r.code != 200) throw std::runtime_error("HTTP POST Error");
delete conn;
disable();
return r.body;
postRequest.set_body(postStr);
// xacc::info("POSTING: " + postStr + " to " + remoteUrl + ", " + path);// << "\n";
// Post the problem, get the response as json
auto postResponse = postClient.request(postRequest);
auto respJson = postResponse.get().extract_string().get();
// Map that response to a string
std::stringstream ss;
ss << respJson;
// xacc::info("post response was " + ss.str());// << "\n";
return ss.str();
}
const std::string Client::get(const std::string& remoteUrl,
const std::string RestClient::get(const std::string& remoteUrl,
const std::string& path, std::map<std::string, std::string> headers) {
using namespace RestClient;
Response r = RestClient::get(remoteUrl+path);
if (r.code != 200) throw std::runtime_error("HTTP GET Error");
return r.body;
http_client_config config;
config.set_validate_certificates(false);
http_client getClient(
http::uri_builder(http::uri(remoteUrl)).append_path(U(path)).to_uri(), config);
http_request getRequest(methods::GET);
for (auto& kv : headers) {
getRequest.headers().add(kv.first, kv.second);
}
// xacc::info("Getting IBM at " + remoteUrl + ", " + path);
auto getResponse = getClient.request(getRequest);
// get the result as a string
std::stringstream z;
z << getResponse.get().extract_json().get();
xacc::info("GET RESPONSE: " + z.str());
return z.str();
}
void RemoteAccelerator::execute(std::shared_ptr<AcceleratorBuffer> buffer,
......
......@@ -15,12 +15,19 @@
#include "Accelerator.hpp"
#include "XACC.hpp"
#include "restclient-cpp/connection.h"
#include "restclient-cpp/restclient.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
using namespace utility;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace concurrency::streams;
namespace xacc {
class Client {
class RestClient {
public:
......@@ -34,7 +41,7 @@ public:
std::map<std::string, std::string> headers = std::map<std::string,
std::string> { });
virtual ~Client() {}
virtual ~RestClient() {}
};
......@@ -43,9 +50,9 @@ class RemoteAccelerator : public Accelerator {
public:
RemoteAccelerator() : Accelerator(), restClient(std::make_shared<Client>()) {}
RemoteAccelerator() : Accelerator(), restClient(std::make_shared<RestClient>()) {}
RemoteAccelerator(std::shared_ptr<Client> client) : restClient(client) {}
RemoteAccelerator(std::shared_ptr<RestClient> client) : restClient(client) {}
/**
......@@ -77,7 +84,7 @@ public:
protected:
std::shared_ptr<Client> restClient;
std::shared_ptr<RestClient> restClient;
std::string postPath;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment