12 #ifndef YAPF_COSTCACHE_HPP
13 #define YAPF_COSTCACHE_HPP
15 #include "../../date_func.h"
22 template <
class Types>
26 typedef typename Types::Tpf
Tpf;
27 typedef typename Types::NodeList::Titem
Node;
53 template <
class Types>
57 typedef typename Types::Tpf
Tpf;
58 typedef typename Types::NodeList::Titem
Node;
59 typedef typename Node::Key
Key;
60 typedef typename Node::CachedData CachedData;
61 typedef typename CachedData::Key CacheKey;
70 return *
static_cast<Tpf *
>(
this);
80 CacheKey key(n.GetKey());
81 Yapf().ConnectNodeToCachedData(n, *
new (m_local_cache.
Append()) CachedData(key));
123 template <
class Tsegment>
125 static const int C_HASH_BITS = 14;
129 typedef typename Tsegment::Key
Key;
143 inline Tsegment& Get(
Key &key,
bool *found)
145 Tsegment *item = m_map.
Find(key);
148 item =
new (m_heap.
Append()) Tsegment(key);
162 template <
class Types>
166 typedef typename Types::Tpf
Tpf;
167 typedef typename Types::NodeList::Titem
Node;
168 typedef typename Node::Key
Key;
169 typedef typename Node::CachedData CachedData;
170 typedef typename CachedData::Key CacheKey;
174 Cache &m_global_cache;
181 return *
static_cast<Tpf *
>(
this);
184 inline static Cache& stGetGlobalCache()
186 static int last_rail_change_counter = 0;
187 static Date last_date = 0;
191 if (last_date !=
_date) {
193 DEBUG(yapf, 2,
"Pf time today: %5d ms", _total_pf_time_us / 1000);
194 _total_pf_time_us = 0;
212 if (!
Yapf().CanUseGlobalCache(n)) {
215 CacheKey key(n.GetKey());
217 CachedData &item = m_global_cache.Get(key, &found);
218 Yapf().ConnectNodeToCachedData(n, item);