BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IRegistry< ValueType > Class Template Reference

Templated object registry. More...

Public Member Functions

const ValueType * getItem (const std::string &key) const
 
std::vector< std::string > keys () const
 
size_t size () const
 

Protected Member Functions

void add (const std::string &key, ValueType *item)
 

Private Attributes

std::map< std::string, std::unique_ptr< ValueType > > m_data
 

Detailed Description

template<class ValueType>
class IRegistry< ValueType >

Templated object registry.

Definition at line 33 of file IRegistry.h.

Member Function Documentation

◆ add()

template<class ValueType >
void IRegistry< ValueType >::add ( const std::string &  key,
ValueType *  item 
)
inlineprotected

Definition at line 54 of file IRegistry.h.

55  {
56  if (m_data.find(key) != m_data.end())
57  throw std::runtime_error("Key '" + key + "' already in registry");
58  m_data[key] = std::unique_ptr<ValueType>(item);
59  }
std::map< std::string, std::unique_ptr< ValueType > > m_data
Definition: IRegistry.h:62

References IRegistry< ValueType >::m_data.

◆ getItem()

template<class ValueType >
const ValueType* IRegistry< ValueType >::getItem ( const std::string &  key) const
inline

Definition at line 35 of file IRegistry.h.

36  {
37  auto it = m_data.find(key);
38  if (it == m_data.end())
39  throw std::runtime_error("Key '" + key + "' not found in registry");
40  return it->second.get();
41  }

References IRegistry< ValueType >::m_data.

◆ keys()

template<class ValueType >
std::vector<std::string> IRegistry< ValueType >::keys ( ) const
inline

Definition at line 43 of file IRegistry.h.

44  {
45  std::vector<std::string> result;
46  for (const auto& it : m_data)
47  result.push_back(it.first);
48  return result;
49  }

References IRegistry< ValueType >::m_data.

Referenced by Basic2DParaCrystalBuilder::createSampleByIndex().

◆ size()

template<class ValueType >
size_t IRegistry< ValueType >::size ( ) const
inline

Definition at line 51 of file IRegistry.h.

51 { return m_data.size(); }

References IRegistry< ValueType >::m_data.

Member Data Documentation

◆ m_data

template<class ValueType >
std::map<std::string, std::unique_ptr<ValueType> > IRegistry< ValueType >::m_data
private

The documentation for this class was generated from the following file: