4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include "location-velocity.h"
24 #include "location-log.h"
27 location_velocity_get_type(void)
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);
34 g_once_init_leave(&type_volatile, type);
39 EXPORT_API LocationVelocity *
40 location_velocity_new(guint timestamp, gdouble speed, gdouble direction, gdouble climb)
42 LocationVelocity *velocity = g_slice_new0(LocationVelocity);
43 g_return_val_if_fail(velocity, NULL);
45 velocity->timestamp = timestamp;
46 velocity->speed = speed;
47 velocity->direction = direction;
48 velocity->climb = climb;
53 location_velocity_free(LocationVelocity *velocity)
55 g_return_if_fail(velocity);
56 g_slice_free(LocationVelocity, velocity);
60 location_velocity_equal(const LocationVelocity *velocity1, const LocationVelocity *velocity2)
62 g_return_val_if_fail(velocity1, FALSE);
63 g_return_val_if_fail(velocity2, FALSE);
65 if (velocity1->timestamp == velocity2->timestamp &&
66 velocity1->speed == velocity2->speed &&
67 velocity1->direction == velocity2->direction &&
68 velocity1->climb == velocity2->climb)
73 EXPORT_API LocationVelocity *
74 location_velocity_copy(const LocationVelocity *velocity)
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);