@@ -60,55 +60,78 @@ namespace client
6060 m_authSchemes(authSchemes),
6161 m_serializer(Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider))
6262 {
63- m_serviceName = ServiceNameT;
6463 initClient ();
6564 }
6665
67- AwsSmithyClientT (const AwsSmithyClientT& other):
68- AwsSmithyClientBase (other,
69- Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
70- ServiceNameT,
71- other.m_serviceUserAgentName,
72- Aws::Http::CreateHttpClient (other.m_clientConfiguration),
73- Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
74- m_clientConfiguration{*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get ())},
75- m_endpointProvider{other.m_endpointProvider },
76- m_authSchemeResolver{Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT)},
77- m_authSchemes{other.m_authSchemes },
78- m_serializer{Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider )}
66+ AwsSmithyClientT (const AwsSmithyClientT& other)
67+ : AwsSmithyClientBase(other,
68+ Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
69+ Aws::Http::CreateHttpClient (other.m_clientConfiguration),
70+ Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
71+ m_clientConfiguration(*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get()))
7972 {
80- initClient ();
73+ m_endpointProvider = other.m_endpointProvider ; /* shallow copy */
74+ m_authSchemeResolver = other.m_authSchemeResolver ; /* shallow copy */
75+ m_authSchemes = other.m_authSchemes ;
76+ m_serializer = Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider );
77+ initClient ();
8178 }
8279
8380 AwsSmithyClientT& operator =(const AwsSmithyClientT& other)
8481 {
8582 if (this != &other)
8683 {
87- AwsSmithyClientBase::deepCopy (Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration ),
88- ServiceNameT ,
89- Aws::Http::CreateHttpClient (other. m_clientConfiguration ),
84+ m_clientConfiguration = other.m_clientConfiguration ;
85+ AwsSmithyClientBase::baseCopyAssign (other ,
86+ Aws::Http::CreateHttpClient (m_clientConfiguration),
9087 Aws::MakeShared<ErrorMarshallerT>(ServiceNameT));
91- m_clientConfiguration = * static_cast <ServiceClientConfigurationT*>(m_clientConfig. get ());
92- m_endpointProvider = other.m_endpointProvider ;
93- m_authSchemeResolver = Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT);
88+
89+ m_endpointProvider = other.m_endpointProvider ; /* shallow copy */
90+ m_authSchemeResolver = other. m_authSchemeResolver ; /* shallow copy */
9491 m_authSchemes = other.m_authSchemes ;
9592 m_serializer = Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider );
96- m_errorMarshaller = Aws::MakeShared<ErrorMarshallerT>(ServiceNameT);
9793 initClient ();
9894 }
9995 return *this ;
10096 }
10197
102- AwsSmithyClientT (AwsSmithyClientT&&) = default ;
98+ AwsSmithyClientT (AwsSmithyClientT&& other) :
99+ AwsSmithyClientBase (std::move(static_cast <AwsSmithyClientBase&&>(other)),
100+ Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, std::move(other.m_clientConfiguration))),
101+ m_clientConfiguration{*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get ())},
102+ m_endpointProvider (std::move(other.m_endpointProvider)),
103+ m_authSchemeResolver (std::move(other.m_authSchemeResolver)),
104+ m_authSchemes (std::move(other.m_authSchemes)),
105+ m_serializer (std::move(other.m_serializer))
106+ {
107+ }
103108
104- AwsSmithyClientT& operator =(AwsSmithyClientT&&) = default ;
109+ AwsSmithyClientT& operator =(AwsSmithyClientT&& other)
110+ {
111+ if (this != &other)
112+ {
113+ m_clientConfiguration = std::move (other.m_clientConfiguration );
114+ AwsSmithyClientBase::baseMoveAssign (std::move (static_cast <AwsSmithyClientBase&&>(other)));
115+
116+ m_endpointProvider = std::move (other.m_endpointProvider );
117+ m_authSchemeResolver = std::move (other.m_authSchemeResolver );
118+ m_authSchemes = std::move (other.m_authSchemes );
119+ m_serializer = std::move (other.m_serializer );
120+ }
121+ return *this ;
122+ }
105123
106124 virtual ~AwsSmithyClientT () = default ;
107125
108126 protected:
109127 void initClient () {
110- m_endpointProvider->InitBuiltInParameters (m_clientConfiguration);
111- m_authSchemeResolver->Init (m_clientConfiguration);
128+ if (m_endpointProvider && m_authSchemeResolver) {
129+ m_endpointProvider->InitBuiltInParameters (m_clientConfiguration);
130+ m_authSchemeResolver->Init (m_clientConfiguration);
131+ } else {
132+ AWS_LOGSTREAM_FATAL (ServiceNameT, " Unable to init client: endpoint provider=" << m_endpointProvider
133+ << " or " << " authSchemeResolver=" << m_authSchemeResolver << " are null!" );
134+ }
112135 }
113136
114137 inline const char * GetServiceClientName () const override { return m_serviceName.c_str (); }
@@ -226,7 +249,7 @@ namespace client
226249 const Aws::Http::URI& uri = endpoint.GetURI ();
227250 auto signerRegionOverride = region;
228251 auto signerServiceNameOverride = serviceName;
229- // signer name is needed for some identity resolvers
252+ // signer name is needed for some identity resolvers
230253 if (endpoint.GetAttributes ()) {
231254 if (endpoint.GetAttributes ()->authScheme .GetSigningRegion ()) {
232255 signerRegionOverride = endpoint.GetAttributes ()->authScheme .GetSigningRegion ()->c_str ();
@@ -242,6 +265,10 @@ namespace client
242265 }
243266
244267 protected:
268+ /* Service client specific config, the actual object is stored in AwsSmithyClientBase by pointer
269+ * In order to avoid config object duplication, smithy template client access it by a reference.
270+ * So that base client has it by base config pointer, child smithy client has it by child config reference.
271+ */
245272 ServiceClientConfigurationT& m_clientConfiguration;
246273 std::shared_ptr<EndpointProviderT> m_endpointProvider{};
247274 std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};
0 commit comments