SCM Library
Spherical Cube Map rendering library
 All Classes Files Functions Variables Friends Pages
scm-set.hpp
1 // Copyright (C) 2011-2012 Robert Kooima
2 //
3 // LIBSCM is free software; you can redistribute it and/or modify it under the
4 // terms of the GNU General Public License as published by the Free Software
5 // Foundation; either version 2 of the License, or (at your option) any later
6 // version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITH-
9 // OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 
13 #ifndef SCM_SET_HPP
14 #define SCM_SET_HPP
15 
16 #include <map>
17 
18 #include "scm-item.hpp"
19 
20 //------------------------------------------------------------------------------
21 
24 
25 struct scm_page : public scm_item
26 {
27  scm_page() : scm_item( ), l(-1), t(0) { }
28  scm_page(int f, long long i) : scm_item(f, i), l(-1), t(0) { }
29  scm_page(int f, long long i, int l) : scm_item(f, i), l( l), t(0) { }
30  scm_page(int f, long long i, int l, int t) : scm_item(f, i), l( l), t(t) { }
31 
32  int l;
33  int t;
34 };
35 
36 //------------------------------------------------------------------------------
37 
40 
41 class scm_set
42 {
43 public:
44 
45  scm_page search(scm_page, int);
46  void insert(scm_page, int);
47  void remove(scm_page);
48 
49  scm_page eject(int, long long);
50 
51  bool empty() const;
52 
53 private:
54 
55  std::map<scm_page, int> m;
56 };
57 
58 //------------------------------------------------------------------------------
59 
60 #endif
An scm_item is a reference to a specific page in a specific SCM file.
Definition: scm-item.hpp:24
int t
Cache add time.
Definition: scm-set.hpp:33
int f
File index.
Definition: scm-item.hpp:26
bool empty() const
Return true if the set is empty.
Definition: scm-set.cpp:98
scm_page search(scm_page, int)
Search for the given page in this page set. If found, update the page entry with the current time t t...
Definition: scm-set.cpp:24
scm_page eject(int, long long)
Eject a page from this set to accommodate the addition of a new page.
Definition: scm-set.cpp:61
long long i
Page index.
Definition: scm-item.hpp:27
scm_item()
Initialize an invalid SCM page reference.
Definition: scm-item.hpp:31
void insert(scm_page, int)
Add a page to this set, associated with the current time.
Definition: scm-set.cpp:41
An scm_set represents an a set of active pages, either currently in a cache or awaiting loading...
Definition: scm-set.hpp:41
int l
Cache line index.
Definition: scm-set.hpp:32
An scm_page structure represents an active image page, either currently in a cache or awaiting loadin...
Definition: scm-set.hpp:25