convert line ends
[canaan.git] / prj / cam / src / object / trcache.h
blob865a7b00b7718b98ba3107fc62c6bb07bf561104
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/object/trcache.h,v 1.6 2000/01/29 13:25:21 adurant Exp $
7 #pragma once
8 #ifndef __TRCACHE_H
9 #define __TRCACHE_H
11 #include <comtools.h>
12 #include <objtype.h>
13 #include <traitbas.h>
15 ////////////////////////////////////////////////////////////
16 // DONOR CACHE INTERFACE
20 // Base types
23 typedef ulong TraitID;
24 #define FLUSH_ALL_TRAITS ((TraitID)-1)
25 #define FLUSH_ALL_OBJS OBJ_NULL
27 F_DECLARE_INTERFACE(IDonorCache);
28 F_DECLARE_INTERFACE(IObjectQuery);
31 // Caching flags
34 enum eDonorCacheFlags
36 kDonorCacheSpew = (1 << 0),
37 kDonorCachePermitConcrete = (1 << 1),
38 kDonorCacheLoading = (1 << 2),
42 // Caching parameters
45 typedef ulong ulStatEntries; // Current number of entries in the cache.
47 struct sDonorCacheParams
49 ulong max_entries; // cache size limit
50 ulong flags; // eDonorCacheFlags
53 typedef struct sDonorCacheParams sDonorCacheParams;
56 // Cache statistics
59 struct sDonorCacheStats
61 ulong adds; // entries added
62 ulong drops; // entries dropped
63 ulong hits; // Get donors hit
64 ulong misses; // get donors missed
65 ulong overwrites; // adds of existing entries
66 ulong flushes; // times flushed
70 #undef INTERFACE
71 #define INTEFACE IDonorCache
72 DECLARE_INTERFACE_(IDonorCache,IUnknown)
74 DECLARE_UNKNOWN_PURE();
77 // Get a new trait ID number
79 STDMETHOD_(TraitID,NewTrait)(THIS_ const sTraitDesc* tDesc) PURE;
82 // Add a cache entry
84 STDMETHOD(SetDonor)(THIS_ ObjID obj, TraitID trait, ObjID donor, ObjID through) PURE;
87 // Lookup a cache entry
89 STDMETHOD_(BOOL,GetDonor)(THIS_ ObjID obj, TraitID trait, ObjID* donor, ObjID* through) PURE;
92 // Clear the cache and all statistics
94 STDMETHOD(Clear)(THIS) PURE;
97 // Invalidate an object, or a set of objects. FLUSH_ALL_TRAITS is a valid
98 // trait argument. FLUSH_ALL_OBJS is a valid wildcard object for Flush
100 STDMETHOD(Flush)(THIS_ ObjID obj, TraitID trait) PURE;
101 STDMETHOD(FlushObjSet)(THIS_ IObjectQuery* objs, TraitID traits) PURE;
104 // Set/Get parameters (cache size, etc)
106 STDMETHOD(SetParams)(THIS_ const sDonorCacheParams* params) PURE;
107 STDMETHOD(GetParams)(THIS_ sDonorCacheParams* params) PURE;
110 // Get performace statistics
112 STDMETHOD(GetTotalStats)(THIS_ sDonorCacheStats* stats) PURE;
113 STDMETHOD(GetStatsByTrait)(THIS_ TraitID trait, sDonorCacheStats* stats) PURE;
114 STDMETHOD(GetByTraitName)(THIS_ const char* name, sDonorCacheStats* stats) PURE;
115 STDMETHOD(GetMaxID)() PURE;
116 STDMETHOD(GetCacheEntries)() PURE;
119 // Create the donor cache
122 EXTERN void DonorCacheCreate(void);
125 #endif // __TRCACHE_H