-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseModuleClientContext.cpp
More file actions
136 lines (110 loc) · 4.44 KB
/
Copy pathBaseModuleClientContext.cpp
File metadata and controls
136 lines (110 loc) · 4.44 KB
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
/* Copyright (C) 2021-2026 Advanced Micro Devices, Inc. All rights reserved. */
#include <BaseModuleClientContext.h>
#include <gpuopen.h>
#include <ddPlatform.h>
#include <g_InfoClient.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BaseModuleClientContext::BaseModuleClientContext(
const DDModuleClientContextCreateInfo& createInfo)
: m_createInfo(createInfo)
, m_logger(createInfo.loader)
, m_moduleStatus(DD_RESULT_UNKNOWN)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BaseModuleClientContext::~BaseModuleClientContext()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::Initialize()
{
m_moduleStatus = DD_RESULT_SUCCESS;
return m_moduleStatus;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BaseModuleClientContext::HandleStateChanged(
const DDModuleClientEventStateChanged& eventData)
{
// Do nothing by default
DD_API_UNUSED(eventData);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::QuerySystemInfo(
void* pUserdata,
PFN_ddReceiveText pfnReceiveJson)
{
DD_RESULT result = DD_RESULT_COMMON_INVALID_PARAMETER;
if (pfnReceiveJson != nullptr)
{
Info::InfoClient client;
DDRpcClientCreateInfo clientInfo = {};
clientInfo.clientId = m_createInfo.systemClients[DD_MODULE_SYSTEM_CLIENT_TYPE_ROUTER].id;
clientInfo.hConnection = m_createInfo.connection;
result = client.Connect(clientInfo);
if (result == DD_RESULT_SUCCESS)
{
DynamicBufferByteWriter dynamicWriter;
result = client.QueryInfoAll(*dynamicWriter.Writer());
if (result == DD_RESULT_SUCCESS)
{
const char* pJson = dynamicWriter.DataAsString();
if (pJson != nullptr)
{
pfnReceiveJson(pUserdata, pJson);
}
else
{
result = DD_RESULT_PARSING_INVALID_JSON;
}
}
}
}
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::QuerySystemInfo(
DDModuleClientContext hClientContext,
void* pUserdata,
PFN_ddReceiveText pfnReceiveJson)
{
DD_RESULT result = DD_RESULT_COMMON_INVALID_PARAMETER;
if ((hClientContext != DD_API_INVALID_HANDLE) && (pfnReceiveJson != nullptr))
{
BaseModuleClientContext* pContext = reinterpret_cast<BaseModuleClientContext*>(hClientContext);
result = pContext->QuerySystemInfo(pUserdata, pfnReceiveJson);
}
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::QueryStatus(
DDModuleClientContext hClientContext)
{
DD_RESULT result = DD_RESULT_COMMON_INVALID_PARAMETER;
if (hClientContext != DD_API_INVALID_HANDLE)
{
BaseModuleClientContext* pContext = reinterpret_cast<BaseModuleClientContext*>(hClientContext);
result = pContext->QueryStatus();
}
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::QueryClientProtocolVersion(
DDModuleClientContext hClientContext,
DDApiVersion* pVersion)
{
DD_RESULT result = DD_RESULT_COMMON_INVALID_PARAMETER;
if (hClientContext != DD_API_INVALID_HANDLE)
{
BaseModuleClientContext* pContext = reinterpret_cast<BaseModuleClientContext*>(hClientContext);
result = pContext->QueryClientProtocolVersion(pVersion);
}
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DD_RESULT BaseModuleClientContext::QueryClientProtocolVersion(
DDApiVersion* pVersion)
{
DD_API_UNUSED(pVersion);
// The default implementation here does not provide a version.
return DD_RESULT_COMMON_UNIMPLEMENTED;
}