4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7 * Genie Kim <daejins.kim@samsung.com>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include "location-velocity.h"
27 #include "location-log.h"
30 location_velocity_get_type(void)
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);
37 g_once_init_leave(&type_volatile, type);
42 EXPORT_API LocationVelocity *
43 location_velocity_new(guint timestamp, gdouble speed, gdouble direction, gdouble climb)
45 LocationVelocity *velocity = g_slice_new0(LocationVelocity);
46 g_return_val_if_fail(velocity, NULL);
48 velocity->timestamp = timestamp;
49 velocity->speed = speed;
50 velocity->direction = direction;
51 velocity->climb = climb;
56 location_velocity_free(LocationVelocity *velocity)
58 g_return_if_fail(velocity);
59 g_slice_free(LocationVelocity, velocity);
63 location_velocity_equal(const LocationVelocity *velocity1, const LocationVelocity *velocity2)
65 g_return_val_if_fail(velocity1, FALSE);
66 g_return_val_if_fail(velocity2, FALSE);
68 if (velocity1->timestamp == velocity2->timestamp &&
69 velocity1->speed == velocity2->speed &&
70 velocity1->direction == velocity2->direction &&
71 velocity1->climb == velocity2->climb)
76 EXPORT_API LocationVelocity *
77 location_velocity_copy(const LocationVelocity *velocity)
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);