BioLib  3.9.1
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.TileCache Class Reference

Public Member Functions

 TileCache (SlideSourceBase source, int capacity=200)
 
bool HasTile (TileInformation info)
 
void DisposeTile (TileInformation info)
 
void DisposeTile (TileInfo info)
 
async Task< byte[]> GetTile (TileInformation info)
 
void AddTile (TileInformation tileId, byte[] tile)
 
void Dispose ()
 

Constructor & Destructor Documentation

◆ TileCache()

BioLib.TileCache.TileCache ( SlideSourceBase source,
int capacity = 200 )
100 {
101 this.source = source;
102 this.capacity = capacity;
103 this.cache = new LruCache<TileInformation, byte[]>(capacity);
104 }

Member Function Documentation

◆ AddTile()

void BioLib.TileCache.AddTile ( TileInformation tileId,
byte[] tile )
151 {
152 LruCache<TileInformation, byte[]>.Info inf = new LruCache<TileInformation, byte[]>.Info();
153 inf.Coordinate = tileId.Coordinate;
154 inf.Index = tileId.Index;
155 if (cache == null)
156 cache = new LruCache<TileInformation, byte[]>(capacity);
157 cache.Add(inf, tile);
158 }

◆ Dispose()

void BioLib.TileCache.Dispose ( )
172 {
173 cache.Dispose();
174 }

◆ DisposeTile() [1/2]

void BioLib.TileCache.DisposeTile ( TileInfo info)
127 {
128 for (int i = 0; i < cache.Count; i++)
129 {
130 var inf = new LruCache<TileInformation, byte[]>.Info();
131 cache.RemoveTile(inf);
132 }
133 }

◆ DisposeTile() [2/2]

void BioLib.TileCache.DisposeTile ( TileInformation info)
119 {
120 for (int i = 0; i < cache.Count; i++)
121 {
122 var inf = new LruCache<TileInformation, byte[]>.Info();
123 cache.RemoveTile(inf);
124 }
125 }

◆ GetTile()

async Task< byte[]> BioLib.TileCache.GetTile ( TileInformation info)
135 {
136 LruCache<TileInformation, byte[]>.Info inf = new LruCache<TileInformation, byte[]>.Info();
137 inf.Coordinate = info.Coordinate;
138 inf.Index = info.Index;
139 byte[] data = cache.Get(inf);
140 if (data != null)
141 {
142 return data;
143 }
144 byte[] tile = await LoadTile(info);
145 if (tile != null)
146 AddTile(info, tile);
147 return tile;
148 }

◆ HasTile()

bool BioLib.TileCache.HasTile ( TileInformation info)
106 {
107 LruCache<TileInformation, byte[]>.Info inf = new LruCache<TileInformation, byte[]>.Info();
108 inf.Coordinate = info.Coordinate;
109 inf.Index = info.Index;
110 byte[] data = cache.Get(inf);
111 if (data == null)
112 {
113 return false;
114 }
115 else
116 return true;
117 }

The documentation for this class was generated from the following file: