BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IRegistry< ValueType > Class Template Reference
Collaboration diagram for IRegistry< ValueType >:

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 28 of file IRegistry.h.

Member Function Documentation

◆ getItem()

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

Definition at line 31 of file IRegistry.h.

32  {
33  auto it = m_data.find(key);
34  if (it == m_data.end())
36  "IRegistry::createItem() -> Error. Not existing item key '" + key + "'");
37  return it->second.get();
38  }
std::map< std::string, std::unique_ptr< ValueType > > m_data
Definition: IRegistry.h:60

References IRegistry< ValueType >::m_data.

Referenced by LayersWithAbsorptionBuilder::createSampleByIndex(), and ParticleInVacuumBuilder::createSampleByIndex().

◆ keys()

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

Definition at line 40 of file IRegistry.h.

41  {
42  std::vector<std::string> result;
43  for (auto it = m_data.begin(); it != m_data.end(); ++it)
44  result.push_back(it->first);
45  return result;
46  }

References IRegistry< ValueType >::m_data.

Referenced by LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), and ParticleInVacuumBuilder::createSampleByIndex().

◆ size()

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

Definition at line 48 of file IRegistry.h.

48 { return m_data.size(); }

References IRegistry< ValueType >::m_data.

Referenced by LayersWithAbsorptionBuilder::size(), and ParticleInVacuumBuilder::size().

◆ add()

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

Definition at line 51 of file IRegistry.h.

52  {
53  if (m_data.find(key) != m_data.end())
55  "IRegistry::createItem() -> Error. Already existing item with key '" + key + "'");
56  m_data[key] = std::unique_ptr<ValueType>(item);
57  }

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: