BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IRegistry< ValueType > Class Template Reference

Description

template<class ValueType>
class IRegistry< ValueType >

Templated object registry.

Definition at line 33 of file IRegistry.h.

Collaboration diagram for IRegistry< ValueType >:
[legend]

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
 

Member Function Documentation

◆ add()

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

Definition at line 53 of file IRegistry.h.

54  {
55  ASSERT(m_data.find(key) == m_data.end());
56  m_data[key] = std::unique_ptr<ValueType>(item);
57  }
#define ASSERT(condition)
Definition: Assert.h:45
std::map< std::string, std::unique_ptr< ValueType > > m_data
Definition: IRegistry.h:60

References ASSERT, and 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  ASSERT(it != m_data.end());
39  return it->second.get();
40  }

References ASSERT, and IRegistry< ValueType >::m_data.

◆ keys()

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

Definition at line 42 of file IRegistry.h.

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

References IRegistry< ValueType >::m_data.

◆ size()

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

Definition at line 50 of file IRegistry.h.

50 { 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: