Skip to content

Commit dd9db61

Browse files
committed
update to deep copy
1 parent 7e079b2 commit dd9db61

File tree

8 files changed

+223
-289
lines changed

8 files changed

+223
-289
lines changed

generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,6 @@ namespace DynamoDB
5151
static const char* GetServiceName();
5252
static const char* GetAllocationTag();
5353
inline const char* GetServiceClientName() const override { return "DynamoDB"; }
54-
55-
DynamoDBClient(const DynamoDBClient& other);
56-
57-
DynamoDBClient(DynamoDBClient&& other);
58-
59-
DynamoDBClient& operator=(const DynamoDBClient& other)
60-
{
61-
if(this == &other)
62-
{
63-
return *this;
64-
}
65-
AwsSmithyClientT::operator=(other);
66-
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>::operator=(other);
67-
init(m_clientConfiguration);
68-
return *this;
69-
}
70-
71-
DynamoDBClient& operator=(DynamoDBClient&& other)
72-
{
73-
if(this == &other)
74-
{
75-
return *this;
76-
}
77-
AwsSmithyClientT::operator=(std::move(other));
78-
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>::operator=(std::move(other));
79-
init(m_clientConfiguration);
80-
return *this;
81-
}
8254

8355
typedef DynamoDBClientConfiguration ClientConfigurationType;
8456
typedef DynamoDBEndpointProvider EndpointProviderType;
@@ -2316,7 +2288,6 @@ namespace DynamoDB
23162288
std::shared_ptr<DynamoDBEndpointProviderBase>& accessEndpointProvider();
23172289
private:
23182290
friend class Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>;
2319-
void init(const DynamoDBClientConfiguration& clientConfiguration);
23202291

23212292
void OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint,
23222293
const Aws::String& operationName,

generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clie
116116
{
117117
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region}},
118118
})
119-
{
120-
init(m_clientConfiguration);
121-
}
119+
{}
122120

123121
DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
124122
std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider,
@@ -132,9 +130,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
132130
{
133131
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::SimpleAwsCredentialIdentityResolver>(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}},
134132
})
135-
{
136-
init(m_clientConfiguration);
137-
}
133+
{}
138134

139135
DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
140136
std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider,
@@ -148,9 +144,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
148144
{
149145
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{ Aws::MakeShared<smithy::AwsCredentialsProviderIdentityResolver>(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}}
150146
})
151-
{
152-
init(m_clientConfiguration);
153-
}
147+
{}
154148

155149
/* Legacy constructors due deprecation */
156150
DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) :
@@ -163,9 +157,7 @@ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfigur
163157
{
164158
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}}
165159
})
166-
{
167-
init(m_clientConfiguration);
168-
}
160+
{}
169161

170162
DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
171163
const Client::ClientConfiguration& clientConfiguration) :
@@ -178,9 +170,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
178170
{
179171
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::SimpleAwsCredentialIdentityResolver>(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}
180172
})
181-
{
182-
init(m_clientConfiguration);
183-
}
173+
{}
184174

185175
DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
186176
const Client::ClientConfiguration& clientConfiguration) :
@@ -193,9 +183,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
193183
{
194184
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::AwsCredentialsProviderIdentityResolver>(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}}
195185
})
196-
{
197-
init(m_clientConfiguration);
198-
}
186+
{}
199187
/* End of legacy constructors due deprecation */
200188

201189
DynamoDBClient::~DynamoDBClient()
@@ -208,47 +196,12 @@ std::shared_ptr<DynamoDBEndpointProviderBase>& DynamoDBClient::accessEndpointPro
208196
return m_endpointProvider;
209197
}
210198

211-
void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config)
212-
{
213-
if (!m_clientConfiguration.executor) {
214-
if (!m_clientConfiguration.configFactories.executorCreateFn()) {
215-
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
216-
m_isInitialized = false;
217-
return;
218-
}
219-
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
220-
}
221-
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
222-
m_endpointProvider->InitBuiltInParameters(config);
223-
}
224-
225199
void DynamoDBClient::OverrideEndpoint(const Aws::String& endpoint)
226200
{
227201
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
228202
m_endpointProvider->OverrideEndpoint(endpoint);
229203
}
230204

231-
DynamoDBClient::DynamoDBClient(const DynamoDBClient& other):
232-
AwsSmithyClientT(
233-
*other.m_clientConfig,
234-
GetServiceName(),
235-
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
236-
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG),
237-
other.m_endpointProvider,
238-
Aws::MakeShared<smithy::SigV4AuthSchemeResolver<>>(ALLOCATION_TAG),
239-
other.m_authSchemes),
240-
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>(other)
241-
{
242-
init(m_clientConfiguration);
243-
}
244-
245-
DynamoDBClient::DynamoDBClient(DynamoDBClient&& other):
246-
AwsSmithyClientT(std::move(other)),
247-
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>(std::move(other))
248-
{
249-
init(m_clientConfiguration);
250-
}
251-
252205
BatchExecuteStatementOutcome DynamoDBClient::BatchExecuteStatement(const BatchExecuteStatementRequest& request) const
253206
{
254207
AWS_OPERATION_GUARD(BatchExecuteStatement);

src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,54 +30,60 @@ namespace client
3030
typename EndpointProviderT,
3131
typename SerializerT,
3232
typename ResponseT,
33-
typename MarshallerT>
33+
typename ErrorMarshallerT>
3434
class AwsSmithyClientT : public AwsSmithyClientBase
3535
{
36-
private:
37-
3836
public:
39-
static_assert(std::is_base_of<Aws::Client::AWSErrorMarshaller, MarshallerT>::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller");
37+
static_assert(std::is_base_of<Aws::Client::AWSErrorMarshaller, ErrorMarshallerT>::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller");
4038

4139
explicit AwsSmithyClientT(const ServiceClientConfigurationT& clientConfig, const Aws::String& serviceName,
4240
const std::shared_ptr<Aws::Http::HttpClient>& httpClient,
4341
const std::shared_ptr<Aws::Client::AWSErrorMarshaller>& errorMarshaller,
4442
const std::shared_ptr<EndpointProviderT> endpointProvider,
4543
const std::shared_ptr<ServiceAuthSchemeResolverT>& authSchemeResolver,
4644
const Aws::UnorderedMap<Aws::String, AuthSchemesVariantT>& authSchemes)
47-
: AwsSmithyClientBase(Aws::MakeShared<ServiceClientConfigurationT>(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller),
45+
: AwsSmithyClientBase(Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller),
4846
m_clientConfiguration(*static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get())),
4947
m_endpointProvider(endpointProvider),
5048
m_authSchemeResolver(authSchemeResolver),
5149
m_authSchemes(authSchemes),
5250
m_serializer(Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider))
5351
{
54-
m_serviceName = ServiceNameT;
52+
m_serviceName = ServiceNameT;
53+
initClient();
5554
}
5655

5756
AwsSmithyClientT(const AwsSmithyClientT& other):
58-
AwsSmithyClientBase(Aws::MakeShared<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfig), other.m_serviceName, Aws::Http::CreateHttpClient(*other.m_clientConfig), Aws::MakeShared<MarshallerT>(other.m_serviceName.c_str())),
59-
m_clientConfiguration{*static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get())},
60-
m_endpointProvider{other.m_endpointProvider},
61-
m_authSchemeResolver{other.m_authSchemeResolver},
57+
AwsSmithyClientBase(other,
58+
Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
59+
ServiceNameT,
60+
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
61+
Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
62+
m_clientConfiguration{*static_cast<ServiceClientConfigurationT*>(m_clientConfig.get())},
63+
m_endpointProvider{Aws::MakeShared<EndpointProviderT>(ServiceNameT)},
64+
m_authSchemeResolver{Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT)},
6265
m_authSchemes{other.m_authSchemes},
6366
m_serializer{Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider)}
6467
{
68+
initClient();
6569
}
6670

67-
6871
AwsSmithyClientT& operator=(const AwsSmithyClientT& other)
6972
{
7073
if(this != &other)
7174
{
72-
AwsSmithyClientBase::operator=(other);
73-
m_clientConfiguration = *static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get());
74-
m_endpointProvider = other.m_endpointProvider;
75-
m_authSchemeResolver = other.m_authSchemeResolver;
75+
AwsSmithyClientBase::deepCopy(Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
76+
ServiceNameT,
77+
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
78+
Aws::MakeShared<ErrorMarshallerT>(ServiceNameT));
79+
m_clientConfiguration = *static_cast<ServiceClientConfigurationT*>(m_clientConfig.get());
80+
m_endpointProvider = Aws::MakeShared<EndpointProviderT>(ServiceNameT);
81+
m_authSchemeResolver = Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT);
7682
m_authSchemes = other.m_authSchemes;
77-
m_serializer = Aws::MakeShared<SerializerT>(other.m_serviceName.c_str(), m_clientConfiguration.telemetryProvider);
78-
m_errorMarshaller = Aws::MakeShared<MarshallerT>(other.m_serviceName.c_str());
83+
m_serializer = Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider);
84+
m_errorMarshaller = Aws::MakeShared<ErrorMarshallerT>(ServiceNameT);
85+
initClient();
7986
}
80-
8187
return *this;
8288
}
8389

@@ -88,6 +94,10 @@ namespace client
8894
virtual ~AwsSmithyClientT() = default;
8995

9096
protected:
97+
void initClient() {
98+
m_endpointProvider->InitBuiltInParameters(m_clientConfiguration);
99+
}
100+
91101
inline const char* GetServiceClientName() const override { return m_serviceName.c_str(); }
92102

93103
ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters, EndpointUpdateCallback&& epCallback) const override
@@ -166,7 +176,6 @@ namespace client
166176
return m_serializer->Deserialize(std::move(httpResponseOutcome), GetServiceClientName(), requestName);
167177
}
168178

169-
protected:
170179
ServiceClientConfigurationT& m_clientConfiguration;
171180
std::shared_ptr<EndpointProviderT> m_endpointProvider{};
172181
std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};

0 commit comments

Comments
 (0)