/**
 * @file
 * $Id: locator.h 2989 2006-11-12 22:48:19Z plasmahh $
 * $Revision: 2989 $
 * $Author: plasmahh $
 * $Date: 2006-11-12 23:48:19 +0100 (So, 12 Nov 2006) $
 *
 * 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 __IWLOCATOR_REMOTELOCATOR_H
#define __IWLOCATOR_REMOTELOCATOR_H

#include "iwlocator/locator.h"
#include "iwremote/rootartano.h"

namespace iwear
{
    namespace sensor
    {
	namespace location
	{

	    namespace {
class remote_locator_provider_server;
	    }
class remote_locator_provider;
    
/**
 * This is a locator class that can either act as a client and mirror locally
 * some remote locator sensor, or it can optionally act as a server and will
 * provide functionality to outside system from a specified real locator.
 */
class remote_locator : public Locator
{
//		       public remote_locator_provider_server
private:
protected:
    mutable net::RootArtano& ra;

    const Locator* server_locator;

    remote_locator_provider_server* server;
    /**
     * This is the remote connection to another locator. It is mutable and
     * non-const since we own it and its creation could be delayed until a
     * const get function is called upon us.
     * @note This is a forward declared type only visible within an anonymous
     * namespace within the .cpp file.
     */
    mutable remote_locator_provider* client_locator;


    // Save them for reuse on the ondemand thing
    uid client_id;
    net::resolve_behaviour client_resbehave;
    net::search_behaviour client_searchbehave;
public:
    /**
     * Using this ctor will make the remote_locator act as a server, providing
     * its information for outside systems.
     */
    remote_locator( LocationManager*, const Locator& loc,
	    net::RootArtano&, net::resolve_behaviour = net::direct_associate , net::search_behaviour = net::search_known);

    /**
     * Using this ctor will make the remote_locator act as a client trying to
     * reach the specified locator. If the locator could not be found during
     * construction phase, nothing bad happens. But when the locator is still
     * not found upon trying to use it, an exception will be thrown indicating
     * a possible error cause.
     */
    remote_locator( LocationManager*, const iwear::uid& id,
	    net::RootArtano&, net::resolve_behaviour = net::direct_associate , net::search_behaviour = net::search_known);

    virtual const Location& get_actual_location( void ) const;

    virtual locator_type get_locator_type( void ) const;

    virtual uint32_t activate_power_state( iwear::power_state ) { /** @todo check if we need functionality here*/ }
};

} // namespace iwear
} // namespace sensor
} // namespace location
#endif
