Alexandria  2.14.1
Please provide a description of the project.
CachedProvider.cpp
Go to the documentation of this file.
1 
25 
26 namespace Euclid {
27 namespace XYDataset {
28 
29 
31  : m_provider(provider)
32 {
33 }
34 
35 
37  auto i = m_list_cache.find(group);
38  if (i == m_list_cache.end()) {
39  auto contents = m_provider->listContents(group);
40  i = m_list_cache.insert(std::make_pair(group, contents)).first;
41  }
42  return i->second;
43 }
44 
45 
47  auto i = m_dataset.find(qualified_name);
48  if (i == m_dataset.end()) {
49  auto dataset = m_provider->getDataset(qualified_name);
50  i = m_dataset.insert(std::make_pair(qualified_name, std::move(dataset))).first;
51  }
52  if (i->second)
53  return std::unique_ptr<XYDataset>(new XYDataset(*i->second));
54  else
55  return nullptr;
56 }
57 
58 } // namespace XYDataset
59 } // namespace Euclid
std::string
STL class.
std::shared_ptr< Euclid::XYDataset::XYDatasetProvider >
std::move
T move(T... args)
Euclid::XYDataset::XYDataset
This module provides an interface for accessing two dimensional datasets (pairs of (X,...
Definition: XYDataset.h:59
std::vector
STL class.
Euclid::XYDataset::CachedProvider::m_list_cache
std::map< std::string, std::vector< QualifiedName > > m_list_cache
Definition: CachedProvider.h:91
Euclid::XYDataset::QualifiedName
Represents a name qualified with a set of groups.
Definition: QualifiedName.h:66
Euclid::XYDataset::CachedProvider::listContents
std::vector< QualifiedName > listContents(const std::string &group) override
Virtual function to list all files contents in the "group" path.
Definition: CachedProvider.cpp:36
Euclid::XYDataset::CachedProvider::getDataset
std::unique_ptr< XYDataset > getDataset(const QualifiedName &qualified_name) override
Virtual function for getting from a qualified name the dataset of XYDataset type.
Definition: CachedProvider.cpp:46
Euclid::XYDataset::CachedProvider::m_dataset
std::map< QualifiedName, std::unique_ptr< XYDataset > > m_dataset
Definition: CachedProvider.h:92
Euclid::XYDataset::CachedProvider::m_provider
std::shared_ptr< XYDatasetProvider > m_provider
Definition: CachedProvider.h:90
CachedProvider.h
std::make_pair
T make_pair(T... args)
std::unique_ptr
STL class.
Euclid
Definition: InstOrRefHolder.h:29
Euclid::XYDataset::CachedProvider::CachedProvider
CachedProvider(std::shared_ptr< XYDatasetProvider > provider)
Definition: CachedProvider.cpp:30