This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
471 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/// | ||
/// @file retdec/internal/service_with_resources_impl.h | ||
/// @copyright (c) 2015-2016 by Petr Zemek (s3rvac@gmail.com) and contributors | ||
/// @license MIT, see the @c LICENSE file for more details | ||
/// @brief Base class of private implementation of services with resources. | ||
/// | ||
|
||
#ifndef RETDEC_INTERNAL_SERVICE_WITH_RESOURCES_IMPL_H | ||
#define RETDEC_INTERNAL_SERVICE_WITH_RESOURCES_IMPL_H | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include <json/json.h> | ||
|
||
#include "retdec/internal/connection_manager.h" | ||
#include "retdec/internal/service_impl.h" | ||
|
||
namespace retdec { | ||
namespace internal { | ||
|
||
/// | ||
/// Base class of private implementation of services. | ||
/// | ||
class ServiceWithResourcesImpl: public ServiceImpl { | ||
public: | ||
ServiceWithResourcesImpl(const Settings &settings, | ||
const std::shared_ptr<ConnectionManager> &connectionManager, | ||
const std::string &serviceName, | ||
const std::string &resourcesName); | ||
virtual ~ServiceWithResourcesImpl() override; | ||
|
||
/// | ||
/// Runs a new resource with the given arguments. | ||
/// | ||
template <typename ResourceType> | ||
std::unique_ptr<ResourceType> runResource(const ResourceArguments &args) { | ||
auto conn = connectionManager->newConnection(settings); | ||
auto response = conn->sendPostRequest( | ||
resourcesUrl, | ||
createRequestArguments(args), | ||
createRequestFiles(args) | ||
); | ||
verifyRequestSucceeded(*response); | ||
auto jsonBody = response->bodyAsJson(); | ||
auto id = jsonBody.get("id", "?").asString(); | ||
return std::make_unique<ResourceType>(id, conn); | ||
} | ||
|
||
/// URL to resources. | ||
const std::string resourcesUrl; | ||
}; | ||
|
||
} // namespace internal | ||
} // namespace retdec | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/// | ||
/// @file retdec/test.h | ||
/// @copyright (c) 2015-2016 by Petr Zemek (s3rvac@gmail.com) and contributors | ||
/// @license MIT, see the @c LICENSE file for more details | ||
/// @brief Testing service. | ||
/// | ||
|
||
#ifndef RETDEC_TEST_H | ||
#define RETDEC_TEST_H | ||
|
||
#include <memory> | ||
|
||
#include "retdec/service.h" | ||
|
||
namespace retdec { | ||
|
||
class Settings; | ||
|
||
namespace internal { | ||
|
||
class ConnectionManager; | ||
class TestImpl; | ||
|
||
} // namespace internal | ||
|
||
/// | ||
/// Runner of analyses. | ||
/// | ||
class Test: public Service { | ||
public: | ||
/// @name Construction and Destruction | ||
/// @{ | ||
Test(const Settings &settings); | ||
/// @cond internal | ||
Test(const Settings &settings, | ||
const std::shared_ptr<::retdec::internal::ConnectionManager> &connectionManager); | ||
/// @endcond | ||
virtual ~Test() override; | ||
/// @} | ||
|
||
/// @name Testing | ||
/// @{ | ||
void auth(); | ||
/// @} | ||
|
||
private: | ||
internal::TestImpl *impl() noexcept; | ||
const internal::TestImpl *impl() const noexcept; | ||
}; | ||
|
||
} // namespace retdec | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// | ||
/// @file retdec/internal/service_with_resources_impl.cpp | ||
/// @copyright (c) 2015-2016 by Petr Zemek (s3rvac@gmail.com) and contributors | ||
/// @license MIT, see the @c LICENSE file for more details | ||
/// @brief Implementation of the base class of private implementations of | ||
/// services with resources. | ||
/// | ||
|
||
#include "retdec/internal/service_with_resources_impl.h" | ||
|
||
namespace retdec { | ||
namespace internal { | ||
|
||
/// | ||
/// Constructs a private implementation. | ||
/// | ||
/// @param[in] settings Settings for the service. | ||
/// @param[in] connectionManager Manager of connections. | ||
/// @param[in] serviceName Name of the service. | ||
/// @param[in] resourcesName Name of the resources (plural). | ||
/// | ||
ServiceWithResourcesImpl::ServiceWithResourcesImpl(const Settings &settings, | ||
const std::shared_ptr<ConnectionManager> &connectionManager, | ||
const std::string &serviceName, | ||
const std::string &resourcesName): | ||
ServiceImpl(settings, connectionManager, serviceName), | ||
resourcesUrl(baseUrl + "/" + resourcesName) {} | ||
|
||
/// | ||
/// Destructs the private implementation. | ||
/// | ||
ServiceWithResourcesImpl::~ServiceWithResourcesImpl() = default; | ||
|
||
} // namespace internal | ||
} // namespace retdec |
Oops, something went wrong.