/*
 *  TnMapResourceData.h
 *  OpenGL Map Engine
 *
 *  Created by Thant on 03/25/2013
 *  Copyright 2013 TeleNav Inc. All rights reserved.
 *
 */

#ifndef ITN_MAP_RESOURCE_DATA_H
#define ITN_MAP_RESOURCE_DATA_H

#include <ctime>
#include <vector>
#include <string>

#include <boost/optional.hpp>
#include <foundation/SharedPtr.h>
#include <foundation/WeakPtr.h>
#include <foundation/TnTypes.h>

#include <RenderEngine/TnMapDataRequest.h>
#include <RenderEngine/TnMapResource.h>


class ITnMapResourceData : public TnMapDataRequest
{
public:

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

    ITnMapResourceData();
    virtual ~ITnMapResourceData();
    
    virtual std::string const & GetResourceName() const = 0;
    virtual void SetResource(TnMapResource const & resource) = 0;

    void SetExpirationDate(time_t time);
    boost::optional<time_t> GetExpirationDate() const;

    virtual void SetRequestResult(eTnMapRequestResult result) = 0;

    static std::string const & DefaultCacheName();
    // Uses default cache by default, but this resets it.
    void UseDefaultCache();
    void UseNoCache();
    // Sets the name of the cache to use (assuming it exists).
    void SetCacheName(std::string const &);
    std::string const & GetCacheName() const;

    //If implementing a threadpool (as default engine proxies do), this allows you to assign the request to seperate pools.  
    void SetRequestSource(std::string const & source);
    std::string const & GetRequestSource() const;
    
private:
    
    std::string m_requestSource;

    ITnMapResourceData(ITnMapResourceData const &);               // not defined
    ITnMapResourceData & operator=(ITnMapResourceData const &);   // not defined

    boost::optional<time_t> m_expirationDate;
    std::string m_cacheName;
    static std::string const s_defaultCache;
};


#endif


