/*
 *  TnProtoBufToVectorDataProxyTSI.h
 *
 *  Created by Thant on July 15, 2013.
 *  Copyright 2013 TeleNav. All rights reserved.
 *
 */

#ifndef TN_PROTOBUF_TO_VECTOR_DATA_PROXY_TSI_H
#define TN_PROTOBUF_TO_VECTOR_DATA_PROXY_TSI_H

#include <foundation/SharedPtr.h>
#include <foundation/WeakPtr.h>
#include <GenericProxy/ITnVDProtoBufProxy.h>
#include <RenderEngine/ITnMapVectorDataProxy.h>
#include <foundation/Util/TnPruningMap.h>
#include <GenericProxy/TnTrafficID2LatLon.h>


class TnProtoBufToVectorDataProxyTSI : 
    public ITnMapVectorDataProxy,
    public Tn::Foundation::enable_shared_from_this<TnProtoBufToVectorDataProxyTSI>
{
public:

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

    static TnProtoBufToVectorDataProxyTSI::ptr Create(ITnVDProtoBufProxy::ptr const &,
                                                      TnTrafficID2LatLon::ptr const & tid2LatLon);

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

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

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

private:

    TnProtoBufToVectorDataProxyTSI(ITnVDProtoBufProxy::ptr const &,
                                   TnTrafficID2LatLon::ptr const & tid2LatLon);

    
    ITnVDProtoBufProxy::ptr m_protoBufProxy;

    typedef TnPruningMap<TnMapVectorData::ptr, ITnVDProtoBufData::wptr> PendingRequests;
    PendingRequests  m_pendingRequests;
    TnTrafficID2LatLon::ptr m_tid2LatLon;
};

#endif
