00001 /*---------------------------------------------------------------------------- 00002 MoMu: A Mobile Music Toolkit 00003 Copyright (c) 2010 Nicholas J. Bryan, Jorge Herrera, Jieun Oh, and Ge Wang 00004 All rights reserved. 00005 http://momu.stanford.edu/toolkit/ 00006 00007 Mobile Music Research @ CCRMA 00008 Music, Computing, Design Group 00009 Stanford University 00010 http://momu.stanford.edu/ 00011 http://ccrma.stanford.edu/groups/mcd/ 00012 00013 MoMu is distributed under the following BSD style open source license: 00014 00015 Permission is hereby granted, free of charge, to any person obtaining a 00016 copy of this software and associated documentation files (the 00017 "Software"), to deal in the Software without restriction, including 00018 without limitation the rights to use, copy, modify, merge, publish, 00019 distribute, sublicense, and/or sell copies of the Software, and to 00020 permit persons to whom the Software is furnished to do so, subject to 00021 the following conditions: 00022 00023 The authors encourage users of MoMu to include this copyright notice, 00024 and to let us know that you are using MoMu. Any person wishing to 00025 distribute modifications to the Software is encouraged to send the 00026 modifications to the original authors so that they can be incorporated 00027 into the canonical version. 00028 00029 The Software is provided "as is", WITHOUT ANY WARRANTY, express or implied, 00030 including but not limited to the warranties of MERCHANTABILITY, FITNESS 00031 FOR A PARTICULAR PURPOSE and NONINFRINGEMENT. In no event shall the authors 00032 or copyright holders by liable for any claim, damages, or other liability, 00033 whether in an actino of a contract, tort or otherwise, arising from, out of 00034 or in connection with the Software or the use or other dealings in the 00035 software. 00036 -----------------------------------------------------------------------------*/ 00037 00038 /*----------------------------------------------------------------------------*/ 00049 /*----------------------------------------------------------------------------*/ 00050 00051 #ifndef __MO_LOCATION_H__ 00052 #define __MO_LOCATION_H__ 00053 00054 #include "mo_def.h" 00055 #import <CoreLocation/CoreLocation.h> 00056 #include <vector> 00057 00058 /*----------------------------------------------------------------------------*/ 00063 /*----------------------------------------------------------------------------*/ 00064 @interface LocationDelegate : NSObject <CLLocationManagerDelegate> 00065 { 00066 CLLocationManager *locationManager; 00067 } 00068 @property (nonatomic, retain) CLLocationManager *locationManager; 00069 00070 @end 00071 00072 00073 /*----------------------------------------------------------------------------*/ 00081 /*----------------------------------------------------------------------------*/ 00082 typedef void (* MoLocationCallback)( CLLocation * newLocation, 00083 CLLocation * oldLocation, 00084 void * data ); 00085 00086 00087 /*----------------------------------------------------------------------------*/ 00099 /*----------------------------------------------------------------------------*/ 00100 class MoLocation 00101 { 00102 public: 00103 // getting values 00104 00106 static void addCallback( const MoLocationCallback & callback, void * data ); 00107 00109 static void removeCallback( const MoLocationCallback & callback ); 00110 00111 00113 static CLLocation * getLocation(); 00114 00116 static CLLocation * getOldLocation(); 00117 00118 /* 00119 Location Attributes 00120 coordinate property 00121 altitude property 00122 horizontalAccuracy property 00123 verticalAccuracy property 00124 timestamp property 00125 – description 00126 Measuring the Distance Between Coordinates 00127 – getDistanceFrom: 00128 Getting Speed and Course Information 00129 speed property 00130 course property 00131 */ 00132 00133 public: 00135 static void update( CLLocation * newLoc, CLLocation * oldLoc ); 00136 00137 private: 00138 00139 00140 // set up the Location delegate 00141 static void checkSetup(); 00142 00143 // current values; 00144 static CLLocation * m_newLocation; 00145 static CLLocation * m_oldLocation; 00146 00147 static LocationDelegate * locationDelegate; 00148 00149 // queue of callbacks 00150 static std::vector< MoLocationCallback > m_clients; 00151 static std::vector<void *> m_clientData; 00152 00153 }; 00154 00155 00156 #endif