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

Description

This can hold any item which belongs to a sample.

Removes the need to derive every xxxItem from a same base class and then try dynamic_cast'ing it.

Definition at line 33 of file SampleItem.h.

Inheritance diagram for SampleItem:
[legend]
Collaboration diagram for SampleItem:
[legend]

Public Member Functions

template<typename T >
 SampleItem (T *item)
 
template<typename T >
get_if ()
 Short version to get a contained pointer (the std::get_if would return pointer-to-pointer) More...
 

Private Types

using base = VariantForSampleItems
 

Member Typedef Documentation

◆ base

Definition at line 51 of file SampleItem.h.

Constructor & Destructor Documentation

◆ SampleItem()

template<typename T >
SampleItem::SampleItem ( T *  item)
inline

Definition at line 36 of file SampleItem.h.

37  : base(item)
38  {
39  }
VariantForSampleItems base
Definition: SampleItem.h:51

Member Function Documentation

◆ get_if()

template<typename T >
T SampleItem::get_if ( )
inline

Short version to get a contained pointer (the std::get_if would return pointer-to-pointer)

Definition at line 43 of file SampleItem.h.

44  {
45  if (T* pp = std::get_if<T>(this))
46  return *pp;
47  return nullptr;
48  }

Referenced by SampleView::onAboutToRemoveItem(), and SampleView::onRequestViewInRealSpace().


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