File size: 10,024 Bytes
053b80b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef __TESTCLIENT_H__
#define __TESTCLIENT_H__

#include <string>
#include <future>
#include <functional>
#include <exception>

#include "messages/Frame.pb.h"
#include "messages/Test.pb.h"

#include "common/Frame.h"
#include "client/IRouterClient.h"
#include "client/NotificationHandler.h"

#if __cplusplus >= 201402L
#define DEPRECATED [[ deprecated ]]
#define DEPRECATED_MSG(msg) [[ deprecated(msg) ]]
#elif defined(__GNUC__)
#define DEPRECATED __attribute__ ((deprecated))
#define DEPRECATED_MSG(msg) __attribute__ ((deprecated(msg)))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#define DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#else
#define DEPRECATED 
#define DEPRECATED_MSG 
#endif
namespace Kinova
{
namespace Api
{
	namespace Test
	{
		// todogr move somewhere else
		const std::string   none = "";
		
		enum FunctionUids

		{
			eUidSetMockValidationStruct = 0xff00001,
			eUidTestParamAndReturn = 0xff00002,
			eUidTestParamOnly = 0xff00003,
			eUidTestReturnOnly = 0xff00004,
			eUidTestTimeout = 0xff00005,
			eUidTestNotif = 0xff00006,
			eUidTestNotifUnsubscribe = 0xff00007,
			eUidTestAsync = 0xff00008,
			eUidTestConcurrence = 0xff00009,
			eUidTestTriggerNotif = 0xff0000a,
			eUidTestNotImplemented = 0xff0000b,
			eUidServerError = 0xff0000c,
			eUidUnsubscribe = 0xff0001e,
			eUidSomethingChangeTopic = 0xff0001f,
			eUidTriggerSomethingChangeTopic = 0xff00020,
			eUidWait = 0xff00021,
			eUidThrow = 0xff00022,
			eUidDisconnect = 0xff00023,
			eUidForget = 0xff00024,
			eUidNotImplemented = 0xff00025,
			eUidDeprecated = 0xff00027,
			eUidDeprecatedWithMessage = 0xff00028,
		};
		
		class TestClient

		{
			static const uint32_t m_serviceVersion = 1;
			static const uint32_t m_serviceId = eIdTest;
			NotificationHandler m_notificationHandler;

		protected:
			IRouterClient* const m_clientRouter;

		public:
			TestClient(IRouterClient* clientRouter);
			static uint32_t getUniqueFctId(uint16_t fctId);

			void SetMockValidationStruct(const validateStruct& validatestruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void SetMockValidationStruct_callback(const validateStruct& validatestruct, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> SetMockValidationStruct_async(const validateStruct& validatestruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			RcvStruct TestParamAndReturn(const SendStruct& sendstruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestParamAndReturn_callback(const SendStruct& sendstruct, std::function< void (const Error&, const RcvStruct&) > callback, uint32_t deviceId = 0);
			std::future<RcvStruct> TestParamAndReturn_async(const SendStruct& sendstruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestParamOnly(const SendStruct& sendstruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestParamOnly_callback(const SendStruct& sendstruct, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestParamOnly_async(const SendStruct& sendstruct, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			RcvStruct TestReturnOnly(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestReturnOnly_callback(std::function< void (const Error&, const RcvStruct&) > callback, uint32_t deviceId = 0);
			std::future<RcvStruct> TestReturnOnly_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestTimeout(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestTimeout_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestTimeout_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			Kinova::Api::Common::NotificationHandle OnNotificationTestNotif(std::function< void (TestNotification) > callback, const NotifOption& notifoption, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestNotifUnsubscribe(const Kinova::Api::Common::NotificationHandle& notificationhandle, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestAsync(const timeToResponse& timetoresponse, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestAsync_callback(const timeToResponse& timetoresponse, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestAsync_async(const timeToResponse& timetoresponse, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestConcurrence(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestConcurrence_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestConcurrence_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestTriggerNotif(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestTriggerNotif_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestTriggerNotif_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TestNotImplemented(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TestNotImplemented_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TestNotImplemented_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			TestError ServerError(const TestError& testerror, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void ServerError_callback(const TestError& testerror, std::function< void (const Error&, const TestError&) > callback, uint32_t deviceId = 0);
			std::future<TestError> ServerError_async(const TestError& testerror, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void Unsubscribe(const Kinova::Api::Common::NotificationHandle& notificationhandle, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			Kinova::Api::Common::NotificationHandle OnNotificationSomethingChangeTopic(std::function< void (SomethingChanged) > callback, const Kinova::Api::Common::NotificationOptions& notificationoptions, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void TriggerSomethingChangeTopic(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void TriggerSomethingChangeTopic_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> TriggerSomethingChangeTopic_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void Wait(const Delay& delay, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void Wait_callback(const Delay& delay, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> Wait_async(const Delay& delay, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void Throw(const Kinova::Api::Error& error, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void Throw_callback(const Kinova::Api::Error& error, std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> Throw_async(const Kinova::Api::Error& error, uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void Disconnect(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void Disconnect_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> Disconnect_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void Forget(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void Forget_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> Forget_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			void NotImplemented(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			void NotImplemented_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			std::future<void> NotImplemented_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			DEPRECATED void Deprecated(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			DEPRECATED void Deprecated_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			DEPRECATED std::future<void> Deprecated_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});

			DEPRECATED_MSG("Purposely deprecated for test") void DeprecatedWithMessage(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});
			DEPRECATED_MSG("Purposely deprecated for test") void DeprecatedWithMessage_callback(std::function< void (const Error&) > callback, uint32_t deviceId = 0);
			DEPRECATED_MSG("Purposely deprecated for test") std::future<void> DeprecatedWithMessage_async(uint32_t deviceId = 0, const RouterClientSendOptions& options = {false, 0, 3000});


		private:
			void messageHeaderValidation(const Frame& msgFrame){ /* todogr ... */ }
		};
	}
}
}

#endif