File diff r18781:e1de9a06f7cd → r18782:6453522c2154
src/pathfinder/yapf/yapf_costcache.hpp
Show inline comments
 
@@ -27,22 +27,22 @@ public:
 
	typedef typename Types::NodeList::Titem Node; ///< this will be our node type
 

	
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	inline bool PfNodeCacheFetch(Node& n)
 
	{
 
		return false;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	inline void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 

	
 
/**
 
@@ -62,34 +62,34 @@ public:
 
	typedef SmallArray<CachedData> LocalCache;
 

	
 
protected:
 
	LocalCache      m_local_cache;
 

	
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	inline Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	inline bool PfNodeCacheFetch(Node& n)
 
	{
 
		CacheKey key(n.GetKey());
 
		Yapf().ConnectNodeToCachedData(n, *new (m_local_cache.Append()) CachedData(key));
 
		return false;
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	inline void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 

	
 
/**
 
@@ -130,22 +130,22 @@ struct CSegmentCostCacheT
 
	typedef SmallArray<Tsegment> Heap;
 
	typedef typename Tsegment::Key Key;    ///< key to hash table
 

	
 
	HashTable    m_map;
 
	Heap         m_heap;
 

	
 
	FORCEINLINE CSegmentCostCacheT() {}
 
	inline CSegmentCostCacheT() {}
 

	
 
	/** flush (clear) the cache */
 
	FORCEINLINE void Flush()
 
	inline void Flush()
 
	{
 
		m_map.Clear();
 
		m_heap.Clear();
 
	}
 

	
 
	FORCEINLINE Tsegment& Get(Key& key, bool *found)
 
	inline Tsegment& Get(Key& key, bool *found)
 
	{
 
		Tsegment *item = m_map.Find(key);
 
		if (item == NULL) {
 
			*found = false;
 
			item = new (m_heap.Append()) Tsegment(key);
 
			m_map.Push(*item);
 
@@ -174,21 +174,21 @@ public:
 
	typedef typename CachedData::Key CacheKey;
 
	typedef CSegmentCostCacheT<CachedData> Cache;
 

	
 
protected:
 
	Cache&      m_global_cache;
 

	
 
	FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
 
	inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
 

	
 
	/** to access inherited path finder */
 
	FORCEINLINE Tpf& Yapf()
 
	inline Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
	FORCEINLINE static Cache& stGetGlobalCache()
 
	inline static Cache& stGetGlobalCache()
 
	{
 
		static int last_rail_change_counter = 0;
 
		static Date last_date = 0;
 
		static Cache C;
 

	
 
		/* some statistics */
 
@@ -208,13 +208,13 @@ protected:
 

	
 
public:
 
	/**
 
	 * Called by YAPF to attach cached or local segment cost data to the given node.
 
	 *  @return true if globally cached data were used or false if local data was used
 
	 */
 
	FORCEINLINE bool PfNodeCacheFetch(Node& n)
 
	inline bool PfNodeCacheFetch(Node& n)
 
	{
 
		if (!Yapf().CanUseGlobalCache(n)) {
 
			return Tlocal::PfNodeCacheFetch(n);
 
		}
 
		CacheKey key(n.GetKey());
 
		bool found;
 
@@ -224,12 +224,12 @@ public:
 
	}
 

	
 
	/**
 
	 * Called by YAPF to flush the cached segment cost data back into cache storage.
 
	 *  Current cache implementation doesn't use that.
 
	 */
 
	FORCEINLINE void PfNodeCacheFlush(Node& n)
 
	inline void PfNodeCacheFlush(Node& n)
 
	{
 
	}
 
};
 

	
 
#endif /* YAPF_COSTCACHE_HPP */