/*
 *  GenericProxyFactory.h
 *  OpenGL Map Engine
 *
 *  Created by Matthew Thompson on August 11 2011
 *  Copyright 2009 TeleNav Inc. All rights reserved.
 */

#ifndef __TN_GENERIC_PROXY_FACTORY_H__
#define __TN_GENERIC_PROXY_FACTORY_H__

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

#include <RenderEngine/TnDeprecate.h>


class TnCache;

class TnGenericRouteProxy;
class TnGenericVectorDataProxy;
class TnGenericTrafficHttpProxy;
class TnGenericLandmarkProxy;

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

class TnProtoBufToTrafficDataProxy;
class TnTrafficProtoBufProxy;
class TnProtoBufToVectorDataProxy;
class TnVectorProtoBufProxy;

class TnNavSimulator;
class TnPrefetch;


class GenericProxyFactory : public ITnMapProxyFactory
{
public:
    
    typedef Tn::Foundation::shared_ptr<GenericProxyFactory> ptr;
    
    GenericProxyFactory(size_t numResourceThreads,
                        std::string const & BINGRasterAPIKey,
                        TnFileNameTranslatorFunc transfunc = 0);
    virtual ~GenericProxyFactory();
    
    //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;

private:
    
    TnFileNameTranslatorFunc m_translator;

    static std::string const BundleFile(std::string const & name);
    
    //various caches for resources
    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<TnProtoBufToTrafficDataProxy> m_trafficProxy;
    Tn::Foundation::shared_ptr<TnTrafficProtoBufProxy>       m_trafficDataProtoBufProxy;
    
    // Vector Data Proxy
    Tn::Foundation::shared_ptr<TnProtoBufToVectorDataProxy> m_vectorDataProxy;
    Tn::Foundation::shared_ptr<TnVectorProtoBufProxy>    m_vectorDataProtoBufProxy;
    
    Tn::Foundation::shared_ptr<ITnMapGlyphProxy> m_glyphProxy;
};

#endif // #ifndef __TN_GENERIC_PROXY_FACTORY_H__

