-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start working on attaching EchoConsole to Echo as a Service
- Loading branch information
1 parent
161fcb6
commit f65605a
Showing
5 changed files
with
102 additions
and
0 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
Empty file.
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,68 @@ | ||
#ifndef SERVICES_CONSOLE_SERVICE_HPP | ||
#define SERVICES_CONSOLE_SERVICE_HPP | ||
|
||
#include "infra/util/SharedOptional.hpp" | ||
#include "protobuf/echo/Echo.hpp" | ||
#include "services/echo_console/Console.hpp" | ||
#include <cstdlib> | ||
|
||
namespace services | ||
{ | ||
class GenericMethodDeserializer | ||
: public MethodDeserializer | ||
{ | ||
public: | ||
void MethodContents(infra::SharedPtr<infra::StreamReaderWithRewinding>&& reader) override | ||
{ | ||
int a = 3; | ||
a++; | ||
} | ||
|
||
void ExecuteMethod() override | ||
{ | ||
int a = 3; | ||
a++; | ||
} | ||
|
||
bool Failed() const override | ||
{ | ||
return false; | ||
} | ||
}; | ||
|
||
class ConsoleServiceMethodExecute | ||
{ | ||
public: | ||
ConsoleServiceMethodExecute(application::Console& console) | ||
: console(console) | ||
{} | ||
|
||
infra::SharedPtr<MethodDeserializer> StartMethod(uint32_t serviceId, uint32_t methodId, uint32_t size, const EchoErrorPolicy& errorPolicy) | ||
{ | ||
return methodDeserializer.Emplace(); | ||
} | ||
|
||
private: | ||
application::Console& console; | ||
infra::SharedOptional<GenericMethodDeserializer> methodDeserializer; | ||
}; | ||
|
||
class ConsoleService | ||
: public Service | ||
{ | ||
public: | ||
ConsoleService(Echo& echo, uint32_t serviceId, ConsoleServiceMethodExecute& methodExecute) | ||
: Service(echo, serviceId) | ||
, methodExecute(methodExecute) | ||
{} | ||
|
||
infra::SharedPtr<MethodDeserializer> StartMethod(uint32_t serviceId, uint32_t methodId, uint32_t size, const EchoErrorPolicy& errorPolicy) override | ||
{ | ||
return methodExecute.StartMethod(serviceId, methodId, size, errorPolicy); | ||
} | ||
|
||
private: | ||
ConsoleServiceMethodExecute& methodExecute; | ||
}; | ||
} | ||
#endif // CONSOLESERVICE_HPP |
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,12 @@ | ||
add_executable(services.echo_console_test) | ||
emil_build_for(services.echo_console_test BOOL EMIL_BUILD_TESTS) | ||
emil_add_test(services.echo_console_test) | ||
|
||
target_sources(services.echo_console_test PRIVATE | ||
TestConsoleService.cpp | ||
) | ||
|
||
target_link_libraries(services.echo_console_test PUBLIC | ||
gmock_main | ||
services.console_service | ||
) |
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,8 @@ | ||
#include "services/echo_console/ConsoleService.hpp" | ||
|
||
class ConsoleServiceTest | ||
: public testing::Test | ||
{ | ||
public: | ||
|
||
}; |