ScummVM API documentation
imagcach.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  *
21  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_IMAGCACH_H
27 #define SAGA2_IMAGCACH_H
28 
29 namespace Saga2 {
30 
31 /* ===================================================================== *
32  ImageNode class which defines a re-entrant image resource
33  * ===================================================================== */
34 
35 class CImageNode {
36 private:
37  uint32 _contextID; // ID of context
38  uint32 _resourceID; // RES_ID of image
39 
40  uint16 _requested; // the number of allocation requests made to node
41  void *_image; // the image
42 
43 public:
44  CImageNode(hResContext *con, uint32 resID);
45  ~CImageNode();
46 
47  void *getImagePtr();
48  bool isSameImage(hResContext *con, uint32 resID);
49  bool isSameImage(void *imagePtr);
50  uint16 getNumRequested() {
51  return _requested;
52  }
53  bool releaseRequest();
54 };
55 
56 
57 /* ===================================================================== *
58  ImageCache class which maintains a list of ImageNodes
59  * ===================================================================== */
60 
61 class CImageCache {
62 private:
63  Common::List<CImageNode *> _nodes; // list of ImageNode
64 
65 public:
66  CImageCache() {
67  assert(_nodes.empty());
68  }
69  ~CImageCache();
70 
71  void *requestImage(hResContext *con, uint32 resID);
72  void releaseImage(void *);
73 };
74 
75 } // end of namespace Saga2
76 
77 #endif
Definition: actor.h:32
Definition: imagcach.h:61
Definition: list.h:44
Definition: hresmgr.h:98
Definition: imagcach.h:35
bool empty() const
Definition: list.h:219