add log messages
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / SearchPreference.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd 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  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Preferences for route search requests
24     /// </summary>
25     public class SearchPreference : IGeocodePreference, IPlaceSearchPreference, IRouteSearchPreference, IDisposable
26     {
27         internal Interop.PreferenceHandle handle;
28         private IReadOnlyDictionary<string, string> _properties = new Dictionary<string, string>();
29
30         /// <summary>
31         /// Constructor for search preference
32         /// </summary>
33         public SearchPreference()
34         {
35             handle = new Interop.PreferenceHandle();
36         }
37
38         /// <summary>
39         /// Constructor for search preference
40         /// </summary>
41         internal SearchPreference(Interop.PreferenceHandle nativeHandle)
42         {
43             handle = nativeHandle;
44         }
45
46         /// <summary>
47         /// Preferred language
48         /// </summary>
49         /// <remarks>
50         /// Language should be specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code e.g. "ko-KR"
51         /// </remarks>
52         public string Language
53         {
54             get
55             {
56                 return handle.Language;
57             }
58             set
59             {
60                 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
61                 handle.Language = value;
62             }
63         }
64
65         /// <summary>
66         /// Maximum result count for a service request
67         /// </summary>
68         /// <remarks>Setting negative value will not have any effect on MaxResults value</remarks>
69         public int MaxResults
70         {
71             get
72             {
73                 return handle.MaxResult;
74             }
75             set
76             {
77                 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
78                 handle.MaxResult = value;
79             }
80         }
81
82         /// <summary>
83         /// Distance unit
84         /// </summary>
85         public DistanceUnit Unit
86         {
87             get
88             {
89                 return (DistanceUnit)handle.Unit;
90             }
91             set
92             {
93                 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
94                 handle.Unit = (Interop.DistanceUnit)value;
95             }
96         }
97
98         /// <summary>
99         /// Preferred country
100         /// </summary>
101         public string CountryCode
102         {
103             get
104             {
105                 return handle.CountryCode;
106             }
107             set
108             {
109                 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
110                 handle.CountryCode = value;
111             }
112         }
113
114         /// <summary>
115         /// Search properties as key value pair
116         /// </summary>
117         public IReadOnlyDictionary<string, string> Properties
118         {
119             get
120             {
121                 return _properties;
122             }
123             set
124             {
125                 Log.Info(string.Format("Properties is changed from {0} to {1}", Properties.ToString(), value.ToString()));
126                 _properties = value;
127             }
128         }
129
130         /// <summary>
131         /// Selected route optimization
132         /// </summary>
133         public RouteOptimization Optimization
134         {
135             get
136             {
137                 return (RouteOptimization)handle.Optimization;
138             }
139             set
140             {
141                 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
142                 handle.Optimization = (Interop.RouteOptimization)value;
143             }
144         }
145
146         /// <summary>
147         /// Route transport mode
148         /// </summary>
149         public TransportMode Mode
150         {
151             get
152             {
153                 return (TransportMode)handle.TransportMode;
154             }
155             set
156             {
157                 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
158                 handle.TransportMode = (Interop.RouteTransportMode)value;
159             }
160         }
161
162         /// <summary>
163         /// Route feature weight
164         /// </summary>
165         public RouteFeatureWeight RouteFeatureWeight
166         {
167             get
168             {
169                 return (RouteFeatureWeight)handle.FeatureWeight;
170             }
171             set
172             {
173                 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
174                 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
175             }
176         }
177
178         /// <summary>
179         /// Route feature
180         /// </summary>
181         public RouteFeature RouteFeature
182         {
183             get
184             {
185                 return (RouteFeature)handle.Feature;
186             }
187             set
188             {
189                 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
190                 handle.Feature = (Interop.RouteRequestFeature)value;
191             }
192         }
193
194         /// <summary>
195         /// Indicate if search for alternative routes is enabled.
196         /// </summary>
197         public bool SearchAlternativeRoutes
198         {
199             get
200             {
201                 return handle.AlternativesEnabled;
202             }
203             set
204             {
205                 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
206                 handle.AlternativesEnabled = value;
207             }
208         }
209
210         #region IDisposable Support
211         private bool _disposedValue = false;
212
213         protected virtual void Dispose(bool disposing)
214         {
215             if (!_disposedValue)
216             {
217                 handle.Dispose();
218                 _disposedValue = true;
219             }
220         }
221
222         public void Dispose()
223         {
224             Dispose(true);
225             GC.SuppressFinalize(this);
226         }
227         #endregion
228     }
229 }