1 /*
2 * Copyright (C) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "vibrate_metadata.h"
17
18 namespace OHOS {
19 namespace Media {
20 using namespace std;
VibrateMetadata()21 VibrateMetadata::VibrateMetadata()
22 : vibrateId_(VIBRATE_ID_DEFAULT),
23 data_(DATA_DEFAULT),
24 size_(SIZE_DEFAULT),
25 displayName_(DISPLAY_NAME_DEFAULT),
26 title_(TITLE_DEFAULT),
27 displayLanguage_(DISPLAY_LANGUAGE_DEFAULT),
28 vibrateType_(VIBRATE_TYPE_DEFAULT),
29 sourceType_(SOURCE_TYPE_DEFAULT),
30 dateAdded_(DATE_ADDED_DEFAULT),
31 dateModified_(DATE_MODIFIED_DEFAULT),
32 dateTaken_(DATE_TAKEN_DEFAULT),
33 vibratePlayMode_(VIBRATE_PLAYMODE_NONE)
34 {
35 Init();
36 }
37
Init()38 void VibrateMetadata::Init()
39 {
40 memberFuncMap_[VIBRATE_COLUMN_VIBRATE_ID] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT32,
41 &VibrateMetadata::SetVibrateId);
42 memberFuncMap_[VIBRATE_COLUMN_DATA] = make_pair(RingtoneResultSetDataType::DATA_TYPE_STRING,
43 &VibrateMetadata::SetData);
44 memberFuncMap_[VIBRATE_COLUMN_SIZE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT64,
45 &VibrateMetadata::SetSize);
46 memberFuncMap_[VIBRATE_COLUMN_DISPLAY_NAME] = make_pair(RingtoneResultSetDataType::DATA_TYPE_STRING,
47 &VibrateMetadata::SetDisplayName);
48 memberFuncMap_[VIBRATE_COLUMN_TITLE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_STRING,
49 &VibrateMetadata::SetTitle);
50 memberFuncMap_[VIBRATE_COLUMN_DISPLAY_LANGUAGE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_STRING,
51 &VibrateMetadata::SetDisplayLanguage);
52 memberFuncMap_[VIBRATE_COLUMN_VIBRATE_TYPE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT32,
53 &VibrateMetadata::SetVibrateType);
54 memberFuncMap_[VIBRATE_COLUMN_SOURCE_TYPE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT32,
55 &VibrateMetadata::SetSourceType);
56 memberFuncMap_[VIBRATE_COLUMN_DATE_ADDED] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT64,
57 &VibrateMetadata::SetDateAdded);
58 memberFuncMap_[VIBRATE_COLUMN_DATE_MODIFIED] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT64,
59 &VibrateMetadata::SetDateModified);
60 memberFuncMap_[VIBRATE_COLUMN_DATE_TAKEN] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT64,
61 &VibrateMetadata::SetDateTaken);
62 memberFuncMap_[VIBRATE_COLUMN_PLAY_MODE] = make_pair(RingtoneResultSetDataType::DATA_TYPE_INT32,
63 &VibrateMetadata::SetPlayMode);
64 }
65
SetVibrateId(const VariantData & vibrateId)66 void VibrateMetadata::SetVibrateId(const VariantData &vibrateId)
67 {
68 vibrateId_ = std::get<int32_t>(vibrateId);
69 }
70
GetVibrateId() const71 int32_t VibrateMetadata::GetVibrateId() const
72 {
73 return vibrateId_;
74 }
75
SetData(const VariantData & data)76 void VibrateMetadata::SetData(const VariantData &data)
77 {
78 data_ = std::get<std::string>(data);
79 }
80
GetData() const81 const std::string &VibrateMetadata::GetData() const
82 {
83 return data_;
84 }
85
SetSize(const VariantData & size)86 void VibrateMetadata::SetSize(const VariantData &size)
87 {
88 size_ = std::get<int64_t>(size);
89 }
90
GetSize() const91 int64_t VibrateMetadata::GetSize() const
92 {
93 return size_;
94 }
95
SetDisplayName(const VariantData & displayName)96 void VibrateMetadata::SetDisplayName(const VariantData &displayName)
97 {
98 displayName_ = std::get<std::string>(displayName);
99 }
100
GetDisplayName() const101 const std::string &VibrateMetadata::GetDisplayName() const
102 {
103 return displayName_;
104 }
105
SetTitle(const VariantData & title)106 void VibrateMetadata::SetTitle(const VariantData &title)
107 {
108 title_ = std::get<std::string>(title);
109 }
110
GetTitle() const111 const std::string &VibrateMetadata::GetTitle() const
112 {
113 return title_;
114 }
115
SetDisplayLanguage(const VariantData & displayLanguage)116 void VibrateMetadata::SetDisplayLanguage(const VariantData &displayLanguage)
117 {
118 displayLanguage_ = std::get<std::string>(displayLanguage);
119 }
120
GetDisplayLanguage() const121 const std::string &VibrateMetadata::GetDisplayLanguage() const
122 {
123 return displayLanguage_;
124 }
125
SetVibrateType(const VariantData & vibrateType)126 void VibrateMetadata::SetVibrateType(const VariantData &vibrateType)
127 {
128 vibrateType_ = std::get<int32_t>(vibrateType);
129 }
130
GetVibrateType() const131 int32_t VibrateMetadata::GetVibrateType() const
132 {
133 return vibrateType_;
134 }
135
SetSourceType(const VariantData & sourceType)136 void VibrateMetadata::SetSourceType(const VariantData &sourceType)
137 {
138 sourceType_ = std::get<int32_t>(sourceType);
139 }
140
GetSourceType() const141 int32_t VibrateMetadata::GetSourceType() const
142 {
143 return sourceType_;
144 }
145
SetDateAdded(const VariantData & dateAdded)146 void VibrateMetadata::SetDateAdded(const VariantData &dateAdded)
147 {
148 dateAdded_ = std::get<int64_t>(dateAdded);
149 }
150
GetDateAdded() const151 int64_t VibrateMetadata::GetDateAdded() const
152 {
153 return dateAdded_;
154 }
155
SetDateModified(const VariantData & dateModified)156 void VibrateMetadata::SetDateModified(const VariantData &dateModified)
157 {
158 dateModified_ = std::get<int64_t>(dateModified);
159 }
160
GetDateModified() const161 int64_t VibrateMetadata::GetDateModified() const
162 {
163 return dateModified_;
164 }
165
SetDateTaken(const VariantData & dateTaken)166 void VibrateMetadata::SetDateTaken(const VariantData &dateTaken)
167 {
168 dateTaken_ = std::get<int64_t>(dateTaken);
169 }
170
GetDateTaken() const171 int64_t VibrateMetadata::GetDateTaken() const
172 {
173 return dateTaken_;
174 }
175
SetPlayMode(const VariantData & playMode)176 void VibrateMetadata::SetPlayMode(const VariantData &playMode)
177 {
178 vibratePlayMode_ = std::get<int32_t>(playMode);
179 }
180
GetPlayMode() const181 int32_t VibrateMetadata::GetPlayMode() const
182 {
183 return vibratePlayMode_;
184 }
185
ToString() const186 string VibrateMetadata::ToString() const
187 {
188 string str = "vibrate metadata:{ vibrateId_=" + to_string(vibrateId_) +
189 "; data_=" + data_ +
190 "; size_=" + to_string(size_) +
191 "; displayName_=" + displayName_ +
192 "; title_=" + title_ +
193 "; displayLanguage_=" + displayLanguage_ +
194 "; vibrateType_=" + to_string(vibrateType_) +
195 "; sourceType_=" + to_string(sourceType_) +
196 "; dateAdded_=" + to_string(dateAdded_) +
197 "; dateModified_=" + to_string(dateModified_) +
198 "; dateTaken_=" + to_string(dateTaken_) + "}";
199 return str;
200 }
201 } // namespace Media
202 } // namespace OHOS
203