1. Change tag style for error log
[platform/core/location/lbs-location.git] / location / manager / location-velocity.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7  *          Genie Kim <daejins.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "location-velocity.h"
27 #include "location-log.h"
28
29 GType
30 location_velocity_get_type(void)
31 {
32         static volatile gsize type_volatile = 0;
33         if (g_once_init_enter(&type_volatile)) {
34                 GType type = g_boxed_type_register_static(g_intern_static_string("LocationVelocity"),
35                                                 (GBoxedCopyFunc) location_velocity_copy, (GBoxedFreeFunc) location_velocity_free);
36
37                 g_once_init_leave(&type_volatile, type);
38         }
39         return type_volatile;
40 }
41
42 EXPORT_API LocationVelocity *
43 location_velocity_new(guint timestamp, gdouble speed, gdouble direction, gdouble climb)
44 {
45         LocationVelocity *velocity = g_slice_new0(LocationVelocity);
46         g_return_val_if_fail(velocity, NULL);
47
48         velocity->timestamp = timestamp;
49         velocity->speed = speed;
50         velocity->direction = direction;
51         velocity->climb = climb;
52         return velocity;
53 }
54
55 EXPORT_API void
56 location_velocity_free(LocationVelocity *velocity)
57 {
58         g_return_if_fail(velocity);
59         g_slice_free(LocationVelocity, velocity);
60 }
61
62 EXPORT_API gboolean
63 location_velocity_equal(const LocationVelocity *velocity1, const LocationVelocity *velocity2)
64 {
65         g_return_val_if_fail(velocity1, FALSE);
66         g_return_val_if_fail(velocity2, FALSE);
67
68         if (velocity1->timestamp == velocity2->timestamp &&
69                 velocity1->speed == velocity2->speed &&
70                 velocity1->direction == velocity2->direction &&
71                 velocity1->climb == velocity2->climb)
72                 return TRUE;
73         return FALSE;
74 }
75
76 EXPORT_API LocationVelocity *
77 location_velocity_copy(const LocationVelocity *velocity)
78 {
79         g_return_val_if_fail(velocity, NULL);
80         LocationVelocity *new_velocity = NULL;
81         new_velocity = location_velocity_new(velocity->timestamp, velocity->speed, velocity->direction, velocity->climb);
82
83         return new_velocity;
84 }