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

#ifndef TN_PROTOBUF_TO_VECTOR_DATA_PROXY_H
#define TN_PROTOBUF_TO_VECTOR_DATA_PROXY_H

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


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

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

    static TnProtoBufToVectorDataProxy::ptr Create(ITnVDProtoBufProxy::ptr const &);

    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:

    TnProtoBufToVectorDataProxy(ITnVDProtoBufProxy::ptr const &);

    
    ITnVDProtoBufProxy::ptr m_protoBufProxy;

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

#endif
