BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GroupInfo Class Reference

Description

Defines info for GroupProperty, i.e. collection of model types, their labels and the name of default item's modelType.

Definition at line 25 of file GroupInfo.h.

Classes

struct  TypeAndLabel
 

Public Member Functions

 GroupInfo (bool is_sorted=true)
 
void add (const QString &itemType, const QString &itemLabel)
 
QString defaultType () const
 
QStringList itemLabels () const
 
QStringList itemTypes () const
 
template<typename T >
void setDefaultType ()
 
void setDefaultType (const QString &modelType)
 

Private Member Functions

bool containsType (const QString &itemType) const
 Default model type for given group (i.e. FFCylinder for formfactor group) More...
 

Private Attributes

bool is_sorted
 
QString m_defaultItemType
 Info will be sorted if true, otherwise order of insertion will be preserved. More...
 
QVector< TypeAndLabelm_info
 

Constructor & Destructor Documentation

◆ GroupInfo()

GroupInfo::GroupInfo ( bool  is_sorted = true)
explicit

Definition at line 18 of file GroupInfo.cpp.

20 {
21 }
bool is_sorted
Definition: GroupInfo.h:55

Member Function Documentation

◆ add()

void GroupInfo::add ( const QString &  itemType,
const QString &  itemLabel 
)

Definition at line 23 of file GroupInfo.cpp.

24 {
25  ASSERT(!containsType(itemType));
26  m_info.push_back({itemType, itemLabel});
27 
28  if (is_sorted)
29  std::sort(m_info.begin(), m_info.end(),
30  [](TypeAndLabel a, TypeAndLabel b) { return a.m_itemType < b.m_itemType; });
31 }
QVector< TypeAndLabel > m_info
Definition: GroupInfo.h:56
bool containsType(const QString &itemType) const
Default model type for given group (i.e. FFCylinder for formfactor group)
Definition: GroupInfo.cpp:62

References containsType(), is_sorted, and m_info.

Here is the call graph for this function:

◆ containsType()

bool GroupInfo::containsType ( const QString &  itemType) const
private

Default model type for given group (i.e. FFCylinder for formfactor group)

Definition at line 62 of file GroupInfo.cpp.

63 {
64  for (const auto& pair : m_info)
65  if (itemType == pair.m_itemType)
66  return true;
67  return false;
68 }

References m_info.

Referenced by add(), and setDefaultType().

◆ defaultType()

QString GroupInfo::defaultType ( ) const

Definition at line 33 of file GroupInfo.cpp.

34 {
35  if (m_defaultItemType.isEmpty() && !m_info.empty())
36  return m_info[0].m_itemType;
37  return m_defaultItemType;
38 }
QString m_defaultItemType
Info will be sorted if true, otherwise order of insertion will be preserved.
Definition: GroupInfo.h:53

References m_defaultItemType, and m_info.

Referenced by GroupItemController::GroupItemController().

◆ itemLabels()

QStringList GroupInfo::itemLabels ( ) const

Definition at line 54 of file GroupInfo.cpp.

55 {
56  QStringList result;
57  for (const auto& pair : m_info)
58  result.append(pair.m_itemLabel);
59  return result;
60 }

References m_info.

Referenced by GroupItemController::itemLabels().

◆ itemTypes()

QStringList GroupInfo::itemTypes ( ) const

Definition at line 46 of file GroupInfo.cpp.

47 {
48  QStringList result;
49  for (const auto& pair : m_info)
50  result.append(pair.m_itemType);
51  return result;
52 }

References m_info.

Referenced by GroupItemController::itemTypes().

◆ setDefaultType() [1/2]

template<typename T >
void GroupInfo::setDefaultType ( )
inline

Definition at line 35 of file GroupInfo.h.

36  {
37  setDefaultType(T::M_TYPE);
38  }
void setDefaultType()
Definition: GroupInfo.h:35

◆ setDefaultType() [2/2]

void GroupInfo::setDefaultType ( const QString &  modelType)

Definition at line 40 of file GroupInfo.cpp.

41 {
42  ASSERT(containsType(modelType));
43  m_defaultItemType = modelType;
44 }

References containsType(), and m_defaultItemType.

Here is the call graph for this function:

Member Data Documentation

◆ is_sorted

bool GroupInfo::is_sorted
private

Definition at line 55 of file GroupInfo.h.

Referenced by add().

◆ m_defaultItemType

QString GroupInfo::m_defaultItemType
private

Info will be sorted if true, otherwise order of insertion will be preserved.

Definition at line 53 of file GroupInfo.h.

Referenced by defaultType(), and setDefaultType().

◆ m_info

QVector<TypeAndLabel> GroupInfo::m_info
private

Definition at line 56 of file GroupInfo.h.

Referenced by add(), containsType(), defaultType(), itemLabels(), and itemTypes().


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