/*
 *  GenericProxyFactoryTSI.h
 *  OpenGL Map Engine
 *
 *  Created by Matthew Thompson on October 10, 2013
 *  Copyright 2013 TeleNav Inc. All rights reserved.
 */

#ifndef __TN_GENERIC_PROXY_FACTORY_TSI_H__
#define __TN_GENERIC_PROXY_FACTORY_TSI_H__

#include <boost/threadpool.hpp>
#include <RenderEngine/ITnMapProxyFactory.h>
#include <GenericProxy/TnFileResourceProxy.h> // for TnFileNameTranslatorFunc
#include <GenericProxy/TnTrafficID2LatLon.h>
#include <GenericProxy/TnTrafficSpeedIcon.h>


class TnCache;

class TnGenericResourceProxy;
class TnGenericRouteProxy;
class TnGenericLandmarkProxy;
class TnGenericRasterTileProxy;

class TnProtoBufToTrafficDataProxyTSI;
class TnProtoBufToVectorDataProxyTSI;

class TnTrafficProtoBufProxy;
class TnVectorProtoBufProxy;

class TnNavSimulator;
class TnPrefetch;


class TnGenericProxyFactoryTSI : public ITnMapProxyFactory
{
public:
    
    typedef Tn::Foundation::shared_ptr<TnGenericProxyFactoryTSI> ptr;
    
    TnGenericProxyFactoryTSI(size_t numResourceThreads,
                             std::string const & BINGRasterAPIKey,
                             TnFileNameTranslatorFunc transfunc = 0);
    virtual ~TnGenericProxyFactoryTSI();
    
    //Goes away in 3.0
    TNMAP_DEPRECATED(void SetVectorDataBaseURL(std::string const & url);)
    TNMAP_DEPRECATED(void SetTrafficDataBaseURL(std::string const & url);)
    void SetVectorURLProperties(std::string const & baseURL, std::string const & postParam);
    void SetTrafficURLProperties(std::string const & baseURL, std::string const & postParam);
    void AddTimestampToTrafficURL(bool add);
    void SetNewStyleTileIdToTrafficURL(bool newStyle);

    /*  ITnMapProxyFactory API
     */

    virtual Tn::Foundation::shared_ptr<ITnMapResourceProxy>     GetResourceProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapRouteProxy>        GetRouteProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapTrafficProxy>      GetTrafficProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapAnnotationProxy>   GetAnnotationProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapLandmarkProxy>     GetLandmarkProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapRasterTileProxy>   GetRasterTileProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapGlyphProxy>        GetGlyphProxy();
    virtual Tn::Foundation::shared_ptr<ITnMapVectorDataProxy>   GetVectorDataProxy();
    
    
    Tn::Foundation::shared_ptr<TnGenericRouteProxy>      GetGenericRouteProxy();
    Tn::Foundation::shared_ptr<TnGenericLandmarkProxy>   GetGenericLandmarkProxy();
    Tn::Foundation::shared_ptr<TnGenericResourceProxy>   GetGenericResourceProxy();
    
    Tn::Foundation::shared_ptr<TnNavSimulator>         GetNavSimulator();
    Tn::Foundation::shared_ptr<TnPrefetch>             GetPrefetch();
    
    Tn::Foundation::shared_ptr<TnCache>                GetDefaultCache() const;
    Tn::Foundation::shared_ptr<TnCache>                GetCityScapeCache() const;
    Tn::Foundation::shared_ptr<TnCache>                GetRasterCache() const;
    Tn::Foundation::shared_ptr<TnCache>                GetHeightmapCache() const;


    void setUnits(eTnSpeedUnits);

private:
    
    TnFileNameTranslatorFunc m_translator;

    static std::string const BundleFile(std::string const & name);
    
    Tn::Foundation::shared_ptr<TnCache> m_defaultCache;
    Tn::Foundation::shared_ptr<TnCache> m_cityScapeCache;
    Tn::Foundation::shared_ptr<TnCache> m_rasterCache;
    Tn::Foundation::shared_ptr<TnCache> m_heightmapCache;
    
    Tn::Foundation::shared_ptr<TnPrefetch> m_prefetch;
    Tn::Foundation::shared_ptr<TnNavSimulator> m_navSimulator;

    Tn::Foundation::shared_ptr<TnGenericResourceProxy>   m_resourceProxy;
    Tn::Foundation::shared_ptr<TnGenericRouteProxy>      m_routeProxy;
    Tn::Foundation::shared_ptr<TnGenericLandmarkProxy>   m_landmarkProxy;
    Tn::Foundation::shared_ptr<TnGenericRasterTileProxy> m_rasterTileProxy;
    
    // Traffic Data Proxy
    Tn::Foundation::shared_ptr<TnProtoBufToTrafficDataProxyTSI> m_trafficProxy;
    Tn::Foundation::shared_ptr<TnTrafficProtoBufProxy>       m_trafficDataProtoBufProxy;
    
    // Vector Data Proxy
    Tn::Foundation::shared_ptr<TnProtoBufToVectorDataProxyTSI> m_vectorDataProxy;
    Tn::Foundation::shared_ptr<TnVectorProtoBufProxy>    m_vectorDataProtoBufProxy;
    
    Tn::Foundation::shared_ptr<ITnMapGlyphProxy> m_glyphProxy;

    TnTrafficID2LatLon::ptr m_tid2LatLon;
};

#endif // #ifndef __TN_GENERIC_PROXY_FACTORY_H__

