GL Studio C++ Runtime API
aif_map_chart_cache.h
Go to the documentation of this file.
1 /*! \file
2  \brief The AIFMapChartLayerCache class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2008 The DiSTI Corporation.<br>
7  11486 Corporate Blvd; Suite 190<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _AIF_MAP_CHART_CACHE_H
41 #define _AIF_MAP_CHART_CACHE_H
42 
44 #include <set>
45 
46 namespace disti
47 {
48 class AifMapChartCell;
49 
50 /** helper class for caching cells between layer changes */
52 {
53 public:
54  /** Ctor */
55  AIFMapChartLayerCache( void ) { _memorySizeMeg = 30u; };
56 
57  /** Dtor - releases all cached cells */
59  {
60  // release all cached cells
61  const unsigned int entryCount = _layerCache.Count();
62  for( unsigned int i = 0u; i < entryCount; ++i )
63  {
64  _layerCache[ i ]->ReleaseCachedCells();
65  }
66  _layerCache.Clear();
67  }
68 
69  /** update the given layer with the latest cells from GetCellList
70  * \param resolution The resolution of the given cell list
71  * \param cellList latest cells from GetCellList for the layer
72  */
73  virtual void UpdateLayer( const double resolution, const MapChartCellList& cellList );
74 
75  /** Get the memory storage amount (Megabytes)
76  * \return max number of layers to cache ( 0u if caching is disabled )
77  */
78  virtual float GetCacheSize( void ) const
79  {
80  return ( _memorySizeMeg );
81  }
82 
83  /** \return The amount of cache used. Calls CurrentSizeMeg() */
84  virtual float GetCacheUsed()
85  {
86  return CurrentSizeMeg();
87  }
88 
89  /** Set the memory storage amount (megabytes)
90  * \param memSize Megabytes of the cache
91  */
92  virtual void SetCacheSize( const float memSize );
93 
94 protected:
95  /** entry for cache info for one layer */
97  {
98  public:
99  /** ctor
100  * \param resolution the resolution for this entry
101  * \param cellList most recent cell list from GetCellList call
102  */
103  LayerCacheEntry( const double resolution, const MapChartCellList& cellList );
104 
105  /** dtor - releases any cached cells */
107  {
109  }
110 
111  /** Get the layer ID associated with this entry
112  * \return layer ID associated with this entry
113  */
114  double GetResolution( void ) const { return ( _resolution ); }
115 
116  /** Release any cached cells */
117  void ReleaseCachedCells( void );
118 
119  /** Merges cells into the collection of cells */
120  void UpdateLatestCells( const MapChartCellList& cellList );
121  void UpdateLatestCellsReplace( const MapChartCellList& cellList );
122 
123  void ReCalcSize();
124 
125  /** Size in megabytes of this cell cache */
126  float SizeMeg()
127  {
128  return _cellsCacheSizeBytes / 1048576.0f;
129  }
130 
131  protected:
132  const double _resolution; /**< resolution associated with this entry */
133  unsigned int _cellsCacheSizeBytes;
134 
135  typedef std::set<AifMapChartCell*> CachedCells;
136  CachedCells _cells; /**< The cached cells */
137  };
138 
139  // Implementation of the current usage
140  virtual float CurrentSizeMeg();
141 
142 private:
143  /**< cache of LayerCacheEntry, last entry in array is always the
144  * current layer */
145  DynamicArray<LayerCacheEntry*> _layerCache;
146 
147  /** Megabyte Memory allocation for AIF Cache */
148  float _memorySizeMeg;
149 };
150 } // namespace disti
151 
152 #endif
LayerCacheEntry(const double resolution, const MapChartCellList &cellList)
Definition: aif_map_chart_cache.h:51
virtual ~AIFMapChartLayerCache()
Definition: aif_map_chart_cache.h:58
virtual void SetCacheSize(const float memSize)
AIFMapChartLayerCache(void)
Definition: aif_map_chart_cache.h:55
Definition: aif_map_chart_cache.h:96
float SizeMeg()
Definition: aif_map_chart_cache.h:126
CachedCells _cells
Definition: aif_map_chart_cache.h:136
The disti::GlsMapChartDataSource class.
virtual float GetCacheSize(void) const
Definition: aif_map_chart_cache.h:78
virtual float GetCacheUsed()
Definition: aif_map_chart_cache.h:84
~LayerCacheEntry()
Definition: aif_map_chart_cache.h:106
void UpdateLatestCells(const MapChartCellList &cellList)
const double _resolution
Definition: aif_map_chart_cache.h:132
Definition: bmpimage.h:46
double GetResolution(void) const
Definition: aif_map_chart_cache.h:114
virtual void UpdateLayer(const double resolution, const MapChartCellList &cellList)