/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 *
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __GPSLOCATOR_H
#define __GPSLOCATOR_H

#ifndef __LOCATOR_H
#include <iwlocator/locator.h>
#endif

#ifndef __UTILITY_H
#include <iwear/utility.h>
#endif

#ifndef __FUNCTOR_H
#include <iwear/functor.h>
#endif

#ifndef __GPS_H
#include <iweargps/gps.h>
#endif

namespace iwear
{
    namespace sensor
    {
        namespace location
        {

class IWGPSLocator : public IWLocator
{
friend void * start_gps_locating( void * v );
public:
   /**
    * @param lm The LocationManager this Locator will be attached to
    * @param pc_hostname Hostname where the gpsd runs, normally "localhost"
    * @param i_port Port where the gpsd listens, normally 2947
    */
    IWGPSLocator( IWLocationManager* lm, char* pc_hostname, int i_port);

   /**
    */
    virtual ~IWGPSLocator();

   /**
    * @name Generic Module interfafe functionality
    * @{
    */

   /**
    * @todo This is currentyl unimplemented, and throw an exception, but 
    * perhaps there is a way to suspend the gpsd
    */
    virtual uint32_t activate_power_state( power_state );

    /**
     * Gathers all the data that is needed to determine our actual location
     */
    void gather_actual_location( void );

   /**
    * @}
    */

   /**
    * @name GPSLocator Interface functionality
    * @{
    */
    virtual const IWLocation& get_actual_location( void ) const;

    virtual locator_type get_locator_type( void ) const { return locator_gps; }
   /**
    * @}
    */

private:
   /**
    * The GPS object of the gps socket to the gpsd
    */
   GPS* gps;

   /**
    * The hostname where the gpsd is connected
    */
   char* pc_hostname;

   /**
    * The port where the gpsd listens
    */
   int i_port;

   /**
    * Thread for getting the data from the gps
    */
   pthread_t LocThread;
};
}
}
}
#endif
