SourceXtractorPlusPlus
0.19
SourceXtractor++, the next generation SExtractor
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SEFramework
SEFramework
Image
TileManager.h
Go to the documentation of this file.
1
17
/*
18
* TileManager.h
19
*
20
* Created on: Feb 23, 2018
21
* Author: mschefer
22
*/
23
24
#ifndef _SEFRAMEWORK_IMAGE_TILEMANAGER_H_
25
#define _SEFRAMEWORK_IMAGE_TILEMANAGER_H_
26
27
#include <iostream>
28
#include <thread>
29
#include <list>
30
#include <unordered_map>
31
32
#include <boost/thread/shared_mutex.hpp>
33
34
#include <
ElementsKernel/Logging.h
>
35
36
#include "
SEFramework/Image/ImageTile.h
"
37
#include "
SEFramework/Image/ImageSource.h
"
38
39
namespace
SourceXtractor {
40
41
42
struct
TileKey
{
43
std::shared_ptr<const ImageSource>
m_source
;
44
int
m_tile_x
,
m_tile_y
;
45
46
bool
operator==
(
const
TileKey
& other)
const
;
47
48
std::string
getRepr
()
const
;
49
};
50
51
inline
std::ostream
&
operator<<
(
std::ostream
& out,
const
TileKey
& tk) {
52
out << tk.
getRepr
();
53
return
out;
54
}
55
56
}
57
58
namespace
std {
59
60
template
<>
61
struct
hash
<SourceXtractor::TileKey> {
62
std::size_t
operator()
(
const
SourceXtractor::TileKey
& key)
const
{
63
std::size_t
local_hash = 0;
64
boost::hash_combine(local_hash, key.
m_source
);
65
boost::hash_combine(local_hash, key.
m_tile_x
);
66
boost::hash_combine(local_hash, key.
m_tile_y
);
67
return
local_hash;
68
}
69
};
70
71
}
72
73
namespace
SourceXtractor {
74
75
class
TileManager
{
76
public
:
77
78
TileManager
();
79
80
virtual
~TileManager
();
81
82
// Actually not thread safe, call before starting the multi-threading
83
void
setOptions
(
int
tile_width,
int
tile_height,
int
max_memory);
84
85
void
flush
();
86
87
std::shared_ptr<ImageTile>
88
getTileForPixel
(
int
x
,
int
y
,
std::shared_ptr<const ImageSource>
source);
89
90
static
std::shared_ptr<TileManager>
getInstance
();
91
92
void
saveAllTiles
();
93
94
int
getTileWidth
()
const
;
95
96
int
getTileHeight
()
const
;
97
98
private
:
99
100
std::shared_ptr<ImageTile>
tryTileFromCache
(
const
TileKey
& key);
101
102
std::shared_ptr<boost::mutex>
&
getMutexForImageSource
(
const
ImageSource
*);
103
104
void
removeTile
(
TileKey
tile_key);
105
106
void
removeExtraTiles
();
107
108
void
addTile
(
TileKey
key,
std::shared_ptr<ImageTile>
tile);
109
110
int
m_tile_width
,
m_tile_height
;
111
long
m_max_memory
;
112
long
m_total_memory_used
;
113
114
std::unordered_map<TileKey, std::shared_ptr<ImageTile>
>
m_tile_map
;
115
std::unordered_map<const ImageSource*, std::shared_ptr<boost::mutex>
>
m_mutex_map
;
116
std::list<TileKey>
m_tile_list
;
117
118
boost::shared_mutex
m_mutex
;
119
};
120
121
}
122
123
124
#endif
/* _SEFRAMEWORK_IMAGE_TILEMANAGER_H_ */
SourceXtractor::TileManager::m_tile_list
std::list< TileKey > m_tile_list
Definition:
TileManager.h:116
std::shared_ptr
ImageSource.h
SourceXtractor::TileManager::flush
void flush()
Definition:
TileManager.cpp:63
SourceXtractor::TileManager::m_tile_width
int m_tile_width
Definition:
TileManager.h:110
SourceXtractor::TileKey::getRepr
std::string getRepr() const
Definition:
TileManager.cpp:35
SourceXtractor::TileManager::getTileWidth
int getTileWidth() const
Definition:
TileManager.cpp:155
Logging.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition:
MoffatModelFittingTask.cpp:94
SourceXtractor::TileManager::~TileManager
virtual ~TileManager()
Definition:
TileManager.cpp:46
SourceXtractor::TileManager::getMutexForImageSource
std::shared_ptr< boost::mutex > & getMutexForImageSource(const ImageSource *)
Definition:
TileManager.cpp:94
SourceXtractor::TileManager::getTileForPixel
std::shared_ptr< ImageTile > getTileForPixel(int x, int y, std::shared_ptr< const ImageSource > source)
Definition:
TileManager.cpp:104
std::size_t
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition:
MoffatModelFittingTask.cpp:94
ImageTile.h
SourceXtractor::TileManager::m_max_memory
long m_max_memory
Definition:
TileManager.h:111
SourceXtractor::TileKey::m_tile_y
int m_tile_y
Definition:
TileManager.h:44
SourceXtractor::TileManager::removeTile
void removeTile(TileKey tile_key)
Definition:
TileManager.cpp:163
std::string
STL class.
SourceXtractor::TileManager::saveAllTiles
void saveAllTiles()
Definition:
TileManager.cpp:147
SourceXtractor::TileManager::TileManager
TileManager()
Definition:
TileManager.cpp:42
std::hash
SourceXtractor::TileKey
Definition:
TileManager.h:42
SourceXtractor::TileManager::tryTileFromCache
std::shared_ptr< ImageTile > tryTileFromCache(const TileKey &key)
Definition:
TileManager.cpp:78
std::hash< SourceXtractor::TileKey >::operator()
std::size_t operator()(const SourceXtractor::TileKey &key) const
Definition:
TileManager.h:62
std::list
STL class.
SourceXtractor::TileManager::m_mutex_map
std::unordered_map< const ImageSource *, std::shared_ptr< boost::mutex > > m_mutex_map
Definition:
TileManager.h:115
SourceXtractor::operator<<
std::ostream & operator<<(std::ostream &out, const TileKey &tk)
Definition:
TileManager.h:51
SourceXtractor::ImageSource
Definition:
ImageSource.h:53
SourceXtractor::TileManager::m_tile_map
std::unordered_map< TileKey, std::shared_ptr< ImageTile > > m_tile_map
Definition:
TileManager.h:114
SourceXtractor::TileManager::m_total_memory_used
long m_total_memory_used
Definition:
TileManager.h:112
SourceXtractor::TileManager::m_mutex
boost::shared_mutex m_mutex
Definition:
TileManager.h:118
SourceXtractor::TileManager::addTile
void addTile(TileKey key, std::shared_ptr< ImageTile > tile)
Definition:
TileManager.cpp:185
SourceXtractor::TileManager::getTileHeight
int getTileHeight() const
Definition:
TileManager.cpp:159
SourceXtractor::TileManager::m_tile_height
int m_tile_height
Definition:
TileManager.h:110
SourceXtractor::TileManager
Definition:
TileManager.h:75
SourceXtractor::TileManager::getInstance
static std::shared_ptr< TileManager > getInstance()
Definition:
TileManager.cpp:140
std::ostream
STL class.
SourceXtractor::TileKey::m_tile_x
int m_tile_x
Definition:
TileManager.h:44
SourceXtractor::TileKey::m_source
std::shared_ptr< const ImageSource > m_source
Definition:
TileManager.h:43
std::unordered_map
STL class.
SourceXtractor::TileKey::operator==
bool operator==(const TileKey &other) const
Definition:
TileManager.cpp:31
SourceXtractor::TileManager::removeExtraTiles
void removeExtraTiles()
Definition:
TileManager.cpp:176
SourceXtractor::TileManager::setOptions
void setOptions(int tile_width, int tile_height, int max_memory)
Definition:
TileManager.cpp:54
Generated by
1.8.5