SourceXtractorPlusPlus  0.11
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MemoryConfig.cpp
Go to the documentation of this file.
1 
17 /*
18  * MemoryConfig.cpp
19  *
20  * Created on: Mar 21, 2018
21  * Author: mschefer
22  */
23 
25 
26 using namespace Euclid::Configuration;
27 namespace po = boost::program_options;
28 
29 namespace SourceXtractor {
30 
31 static const std::string MAX_TILE_MEMORY {"tile-memory-limit"};
32 static const std::string TILE_SIZE {"tile-size"};
33 
34 MemoryConfig::MemoryConfig(long manager_id) : Configuration(manager_id), m_max_memory(512), m_tile_size(256) {
35 }
36 
38  return { {"Memory usage", {
39  {MAX_TILE_MEMORY.c_str(), po::value<int>()->default_value(512), "Maximum memory used for image tiles cache in megabytes"},
40  {TILE_SIZE.c_str(), po::value<int>()->default_value(256), "Image tiles size in pixels"},
41  }}};
42 }
43 
44 void MemoryConfig::initialize(const UserValues& args) {
45  m_max_memory = args.at(MAX_TILE_MEMORY).as<int>();
46  m_tile_size = args.at(TILE_SIZE).as<int>();
47  if (m_max_memory <= 0) {
48  throw Elements::Exception() << "Invalid " << MAX_TILE_MEMORY << " value: " << m_max_memory;
49  }
50  if (m_tile_size <= 0) {
51  throw Elements::Exception() << "Invalid " << TILE_SIZE << " value: " << m_tile_size;
52  }
53 }
54 
55 } /* namespace SourceXtractor */
56 
57 
58 
59 
static const std::string TILE_SIZE
STL class.
static const std::string MAX_TILE_MEMORY
STL class.
std::map< std::string, OptionDescriptionList > getProgramOptions() override
T c_str(T...args)
void initialize(const UserValues &args) override