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

#ifndef TN_PROTOBUF_TRAFFIC_DATA_PROXY_H
#define TN_PROTOBUF_TRAFFIC_DATA_PROXY_H

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

#include <foundation/Util/TnPruningMap.h>

#include <RenderEngine/ITnMapTrafficProxy.h>

#include <GenericProxy/ITnTrafficProtoBufProxy.h>

class TnProtoBufToTrafficDataProxy
    : public ITnMapTrafficProxy,
      public boost::enable_shared_from_this<TnProtoBufToTrafficDataProxy>
{
public:

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

    // To prevent creating an instance on the stack given
    // enable_shared_from_this.
    static TnProtoBufToTrafficDataProxy::ptr Create(ITnTrafficProtoBufProxy::ptr const &);

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

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

    virtual void CancelRequest(TnMapTrafficData::ptr const & data);
    
    virtual void SetTrafficConditions(const std::vector<std::string> & tmcIds, const std::vector<std::string> & conditions) {};

private:

    TnProtoBufToTrafficDataProxy(ITnTrafficProtoBufProxy::ptr const &);

    ITnTrafficProtoBufProxy::ptr m_protoBufProxy;

    typedef TnPruningMap<TnMapTrafficData::ptr, ITnTrafficProtoBufData::wptr> PendingRequests;
    PendingRequests m_pendingRequests;
};


#endif // TN_PROTOBUF_TRAFFIC_DATA_PROXY_H
