removed wrong contacts, added authors
[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  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "location-velocity.h"
24 #include "location-log.h"
25
26 GType
27 location_velocity_get_type(void)
28 {
29         static volatile gsize type_volatile = 0;
30         if (g_once_init_enter(&type_volatile)) {
31                 GType type = g_boxed_type_register_static(g_intern_static_string("LocationVelocity"),
32                                                 (GBoxedCopyFunc) location_velocity_copy, (GBoxedFreeFunc) location_velocity_free);
33
34                 g_once_init_leave(&type_volatile, type);
35         }
36         return type_volatile;
37 }
38
39 EXPORT_API LocationVelocity *
40 location_velocity_new(guint timestamp, gdouble speed, gdouble direction, gdouble climb)
41 {
42         LocationVelocity *velocity = g_slice_new0(LocationVelocity);
43         g_return_val_if_fail(velocity, NULL);
44
45         velocity->timestamp = timestamp;
46         velocity->speed = speed;
47         velocity->direction = direction;
48         velocity->climb = climb;
49         return velocity;
50 }
51
52 EXPORT_API void
53 location_velocity_free(LocationVelocity *velocity)
54 {
55         g_return_if_fail(velocity);
56         g_slice_free(LocationVelocity, velocity);
57 }
58
59 EXPORT_API gboolean
60 location_velocity_equal(const LocationVelocity *velocity1, const LocationVelocity *velocity2)
61 {
62         g_return_val_if_fail(velocity1, FALSE);
63         g_return_val_if_fail(velocity2, FALSE);
64
65         if (velocity1->timestamp == velocity2->timestamp &&
66                 velocity1->speed == velocity2->speed &&
67                 velocity1->direction == velocity2->direction &&
68                 velocity1->climb == velocity2->climb)
69                 return TRUE;
70         return FALSE;
71 }
72
73 EXPORT_API LocationVelocity *
74 location_velocity_copy(const LocationVelocity *velocity)
75 {
76         g_return_val_if_fail(velocity, NULL);
77         LocationVelocity *new_velocity = NULL;
78         new_velocity = location_velocity_new(velocity->timestamp, velocity->speed, velocity->direction, velocity->climb);
79
80         return new_velocity;
81 }