/*
 *  TnVectorProtoBufProxy.h
 *
 *  Created by Thant on November 1, 2013.
 *  Copyright 2013 TeleNav. All rights reserved.
 *
 */


#ifndef TN_VECTOR_PROTOBUF_PROXY_H
#define TN_VECTOR_PROTOBUF_PROXY_H

#include <foundation/SharedPtr.h>
#include <foundation/WeakPtr.h>

#include <RenderEngine/ITnMapResourceProxy.h>
#include <GenericProxy/ITnVDProtoBufProxy.h>
#include <foundation/Util/TnPruningMap.h>


class TnVectorProtoBufProxy :
    public  ITnVDProtoBufProxy,
    public boost::enable_shared_from_this<TnVectorProtoBufProxy>
{
public:

    typedef Tn::Foundation::shared_ptr<TnVectorProtoBufProxy> ptr;
    typedef Tn::Foundation::weak_ptr<TnVectorProtoBufProxy> wptr;

    static TnVectorProtoBufProxy::ptr Create(ITnMapResourceProxy::ptr const &);

    /*  ITnVectorProtoBufProxy
     *
     */

    virtual bool PrefetchSupported() const;
    virtual void RequestTilePrefetch(TnMapTileId const & id);

    virtual void RequestTile(ITnVDProtoBufData::ptr const & data);

    virtual void CancelRequest(ITnVDProtoBufData::ptr const & data);

    /*  TnVectorProtoBufProxy
     *
     */

    void SetBaseURL(std::string const & baseURL);
    void SetPostParameter(std::string const & postParam);

private:

    TnVectorProtoBufProxy(ITnMapResourceProxy::ptr const &);

    std::string BuildUrl(TnMapTileId clientTileId);

    ITnMapResourceProxy::ptr m_resourceProxy;

    typedef TnPruningMap<ITnVDProtoBufData::ptr, ITnMapResourceData::wptr> PendingRequests;
    PendingRequests m_pendingRequests;

    std::string m_baseURL, m_postParameter;
};


#endif // TN_VECTOR_PROTOBUF_PROXY_H
