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 ACSDKMANUFACTORY_ANNOTATED_H_
17 #define ACSDKMANUFACTORY_ANNOTATED_H_
18 
19 #include <memory>
20 
21 namespace alexaClientSDK {
22 namespace acsdkManufactory {
23 
34 template <typename Annotation, typename Type>
35 struct Annotated {
36 public:
38  using element_type = Type;
39 
43  Annotated() = default;
44 
51  Annotated(Type* value);
52 
58  Annotated(const std::shared_ptr<Type>& value);
59 
65  Annotated(std::shared_ptr<Type>&& value);
66 
70  void reset();
71 
77  Type* get() const;
78 
84  Type& operator*() const;
85 
91  Type* operator->() const;
92 
98  operator std::shared_ptr<Type>() const;
99 
105  explicit operator bool() const;
106 
107 private:
109  std::shared_ptr<Type> m_value;
110 };
111 
112 template <typename Annotation, typename Type>
113 inline Annotated<Annotation, Type>::Annotated(Type* value) : m_value{value} {
114 }
115 
116 template <typename Annotation, typename Type>
117 inline Annotated<Annotation, Type>::Annotated(const std::shared_ptr<Type>& value) : m_value{value} {
118 }
119 
120 template <typename Annotation, typename Type>
121 inline Annotated<Annotation, Type>::Annotated(std::shared_ptr<Type>&& value) : m_value{value} {
122 }
123 
124 template <typename Annotation, typename Type>
126  m_value.reset();
127 }
128 
129 template <typename Annotation, typename Type>
131  return m_value.get();
132 }
133 
134 template <typename Annotation, typename Type>
136  return *m_value;
137 }
138 
139 template <typename Annotation, typename Type>
141  return m_value.get();
142 }
143 
144 template <typename Annotation, typename Type>
145 inline Annotated<Annotation, Type>::operator std::shared_ptr<Type>() const {
146  return m_value;
147 }
148 
149 template <typename Annotation, typename Type>
151  return !!m_value;
152 }
153 
154 template <typename Annotation, typename Type>
156  return lhs.get() == rhs.get();
157 };
158 
159 template <typename Annotation, typename Type>
161  return !(lhs == rhs);
162 };
163 
164 template <typename Annotation, typename Type>
165 inline bool operator==(const Annotated<Annotation, Type>& lhs, const std::shared_ptr<Type>& rhs) {
166  return lhs.get() == rhs.get();
167 };
168 
169 template <typename Annotation, typename Type>
170 inline bool operator!=(const Annotated<Annotation, Type>& lhs, const std::shared_ptr<Type>& rhs) {
171  return !(lhs == rhs);
172 };
173 
174 } // namespace acsdkManufactory
175 } // namespace alexaClientSDK
176 
177 #endif // ACSDKMANUFACTORY_ANNOTATED_H_
Type * get() const
Definition: Annotated.h:130
ACSDK_INLINE_VISIBILITY bool operator!=(const Annotated< Annotation, Type > &lhs, const std::shared_ptr< Type > &rhs)
Definition: Annotated.h:179
Type * operator->() const
Definition: Annotated.h:140
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Type & operator*() const
Definition: Annotated.h:135
void reset()
Definition: Annotated.h:125
ACSDK_INLINE_VISIBILITY bool operator==(const Annotated< Annotation, Type > &lhs, const std::shared_ptr< Type > &rhs)
Definition: Annotated.h:172

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