Conceptually the key for the cache is just the hash of the object, but the getter also needs the object to be converted, so we take advantage of the LRUCache's GetterKey feature which allows an augmented key to be passed to the getter, while a simpler key is stored internally.
| 58 | // feature which allows an augmented key to be passed to the |
| 59 | // getter, while a simpler key is stored internally. |
| 60 | struct CacheGetterKey |
| 61 | { |
| 62 | |
| 63 | CacheGetterKey() |
| 64 | : object( nullptr ) |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | CacheGetterKey( const IECore::Object *o ) |
| 69 | : object( o ), hash( o->hash() ) |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | bool operator == ( const CacheGetterKey &other ) const |
| 74 | { |
| 75 | return hash == other.hash; |
| 76 | } |
| 77 | |
| 78 | operator const IECore::MurmurHash & () const |
| 79 | { |
| 80 | return hash; |
| 81 | } |
| 82 | |
| 83 | const IECore::Object *object; |
| 84 | const IECore::MurmurHash hash; |
| 85 | |
| 86 | }; |
| 87 | |
| 88 | } // namespace |
| 89 |