AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Annotated.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_ANNOTATED_H_
17 #define ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_ANNOTATED_H_
18 
19 #include <memory>
20 
22 
23 namespace alexaClientSDK {
24 namespace sdkClient {
25 
36 template <typename Annotation, typename Type>
37 struct Annotated {
38 public:
40  using element_type = Type;
41 
45  Annotated() = default;
46 
54 
60  ACSDK_INLINE_VISIBILITY Annotated(const std::shared_ptr<Type>& value);
61 
67  ACSDK_INLINE_VISIBILITY Annotated(std::shared_ptr<Type>&& value);
68 
73 
79  ACSDK_INLINE_VISIBILITY Type* get() const;
80 
87 
94 
100  ACSDK_INLINE_VISIBILITY operator std::shared_ptr<Type>() const;
101 
107  ACSDK_INLINE_VISIBILITY explicit operator bool() const;
108 
109 private:
111  std::shared_ptr<Type> m_value;
112 };
113 
114 template <typename Annotation, typename Type>
116 }
117 
118 template <typename Annotation, typename Type>
119 ACSDK_INLINE_VISIBILITY inline Annotated<Annotation, Type>::Annotated(const std::shared_ptr<Type>& value) :
120  m_value{value} {
121 }
122 
123 template <typename Annotation, typename Type>
124 ACSDK_INLINE_VISIBILITY inline Annotated<Annotation, Type>::Annotated(std::shared_ptr<Type>&& value) : m_value{value} {
125 }
126 
127 template <typename Annotation, typename Type>
129  m_value.reset();
130 }
131 
132 template <typename Annotation, typename Type>
134  return m_value.get();
135 }
136 
137 template <typename Annotation, typename Type>
139  return *m_value;
140 }
141 
142 template <typename Annotation, typename Type>
144  return m_value.get();
145 }
146 
147 template <typename Annotation, typename Type>
149  return m_value;
150 }
151 
152 template <typename Annotation, typename Type>
154  return !!m_value;
155 }
156 
157 template <typename Annotation, typename Type>
159  const Annotated<Annotation, Type>& lhs,
160  const Annotated<Annotation, Type>& rhs) {
161  return lhs.get() == rhs.get();
162 };
163 
164 template <typename Annotation, typename Type>
166  const Annotated<Annotation, Type>& lhs,
167  const Annotated<Annotation, Type>& rhs) {
168  return !(lhs == rhs);
169 };
170 
171 template <typename Annotation, typename Type>
173  const Annotated<Annotation, Type>& lhs,
174  const std::shared_ptr<Type>& rhs) {
175  return lhs.get() == rhs.get();
176 };
177 
178 template <typename Annotation, typename Type>
180  const Annotated<Annotation, Type>& lhs,
181  const std::shared_ptr<Type>& rhs) {
182  return !(lhs == rhs);
183 };
184 
185 } // namespace sdkClient
186 } // namespace alexaClientSDK
187 
188 #endif // ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_ANNOTATED_H_
ACSDK_INLINE_VISIBILITY Type & operator*() const
Definition: Annotated.h:138
Type element_type
The underlying type that is being annotated.
Definition: Annotated.h:40
Definition: Annotated.h:37
ACSDK_INLINE_VISIBILITY bool operator!=(const Annotated< Annotation, Type > &lhs, const Annotated< Annotation, Type > &rhs)
Definition: Annotated.h:165
ACSDK_INLINE_VISIBILITY Type * operator->() const
Definition: Annotated.h:143
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
#define ACSDK_INLINE_VISIBILITY
Compiler-specific macro for inline-only methods.
Definition: PlatformDefinitions.h:116
ACSDK_INLINE_VISIBILITY Type * get() const
Definition: Annotated.h:133
ACSDK_INLINE_VISIBILITY void reset()
Definition: Annotated.h:128
ACSDK_INLINE_VISIBILITY bool operator==(const Annotated< Annotation, Type > &lhs, const Annotated< Annotation, Type > &rhs)
Definition: Annotated.h:158

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0