![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/OwningDataList.h>
Wrapper class to store a list of owned Data instances. More...
Wrapper class to store a list of owned Data instances.
Internally, this class is merely a std::vector<std::unique_ptr<Data>>. However, it provides a couple of convenience functions for filtering and extracting data. Use a plain DataList to model a view on a list of Data instances without ownership.
Public Member Functions | |
| OwningDataList () | |
| Default Constructor to create an empty list. | |
| template<typename T> | |
| OwningDataList (std::unique_ptr< T > data) | |
| Convenience constructor from a single unique_ptr<Data>. | |
| template<typename T> | |
| OwningDataList (std::vector< std::unique_ptr< T > > &&data) | |
| Constructor from a vector of data. | |
| OwningDataList (OwningDataList &&rhs) noexcept | |
| Move constructor will guarantee that rhs is empty and usable afterwards. | |
| OwningDataList & | operator= (OwningDataList &&rhs) noexcept |
| Move assignment will guarantee that rhs is empty and usable afterwards. | |
| OwningDataList (const OwningDataList &)=delete | |
| OwningDataList & | operator= (const OwningDataList &)=delete |
| virtual void | add (std::unique_ptr< Data > data) |
| Add data to the list. | |
| virtual void | add (OwningDataList &&dataList) |
| Add data to the list. | |
| int | size () const |
| Return the size of the list. | |
| int | indexOf (const Data *data) const |
| Returns the index of data within the list or -1 if it is not present. | |
| void | clear () |
| Clear all data. | |
| bool | operator== (const OwningDataList &other) const |
| Returns true if the both OwningDataList have the same elements in the same order, false otherwise. | |
| bool | operator!= (const OwningDataList &other) const |
| Returns false if the both OwningDataList have the same elements in the same order, true otherwise. | |
Static Public Member Functions | |
| template<typename... Items> | |
| static OwningDataList | create (Items &&... items) |
| Factory function creating an OwningDataList from a list of std::unique_ptr<T>, with T derived from Data. | |
Retrieving items from a OwningDataList | |
| std::unique_ptr< Data > | extractItem (int which) |
| Extract the Data instance of the given index. | |
| std::unique_ptr< Data > | extractFirst (Data::Kind kind=Data::UNKNOWN) |
| Extract the first Data instance of the given kind. | |
| template<typename T> | |
| std::unique_ptr< T > | extractFirst (Data::Kind kind=Data::UNKNOWN) |
| Extract the first Data instance of the given type and kind. | |
| std::vector< std::unique_ptr< Data > > | extractAll (Data::Kind kind=Data::UNKNOWN) |
| Extract all Data instances of given kind. | |
| template<typename T> | |
| std::vector< std::unique_ptr< T > > | extractAll (Data::Kind kind=Data::UNKNOWN) |
| Extract all Data instances of given type and kind. | |
| std::unique_ptr< SharedImageSet > | extractFirstImage (Data::Kind kind=Data::UNKNOWN, Data::Modality modality=Data::NA) |
| Extract the first SharedImageSet instance of given kind and modality. | |
| std::vector< std::unique_ptr< SharedImageSet > > | extractAllImages (Data::Kind kind=Data::UNKNOWN, Data::Modality modality=Data::NA) |
| Extract all SharedImageSet instances of given kind and modality. | |
| Data * | operator[] (int idx) |
| Array access; returns the data located in the underlying vector at the given index. | |
| const Data * | operator[] (int idx) const |
| Array access; returns the data located in the underlying vector at the given index. | |
| DataList | dataListView () const |
| Return a view in form of a DataList onto this OwningDataList. | |
Access to the underlying std::vector holding the data. | |
| std::vector< std::unique_ptr< Data > > & | container () |
| const std::vector< std::unique_ptr< Data > > & | container () const |
| std::vector< std::unique_ptr< Data > >::const_iterator | begin () const |
| std::vector< std::unique_ptr< Data > >::const_iterator | end () const |
| std::vector< std::unique_ptr< Data > >::iterator | begin () |
| std::vector< std::unique_ptr< Data > >::iterator | end () |
|
explicit |
| OwningDataList | ( | std::vector< std::unique_ptr< T > > && | data | ) |
Constructor from a vector of data.
owningDataList2 = owningDataList1.extractAll<SharedImageSet>(); to extract all SharedImageSets from owningDataList1 and assign them to owningDataList2.
|
static |
Factory function creating an OwningDataList from a list of std::unique_ptr<T>, with T derived from Data.
| Items | parameter pack of std::unique_ptr<Data>. |
| std::unique_ptr< Data > extractFirst | ( | Data::Kind | kind = Data::UNKNOWN | ) |
Extract the first Data instance of the given kind.
Data::UNKNOWN will match all kinds.
extractFirst<Data>(kind).
|
inline |
Extract the first Data instance of the given type and kind.
Data::UNKNOWN will match all kinds.
| std::vector< std::unique_ptr< Data > > extractAll | ( | Data::Kind | kind = Data::UNKNOWN | ) |
Extract all Data instances of given kind.
Data::UNKNOWN will match all kinds.
extractAll<Data>(kind). | std::vector< std::unique_ptr< T > > extractAll | ( | Data::Kind | kind = Data::UNKNOWN | ) |
Extract all Data instances of given type and kind.
Data::UNKNOWN will match all kinds.
| std::unique_ptr< SharedImageSet > extractFirstImage | ( | Data::Kind | kind = Data::UNKNOWN, |
| Data::Modality | modality = Data::NA ) |
Extract the first SharedImageSet instance of given kind and modality.
Data::UNKNOWN will match all kinds and Data::NA will match all modalities.
| std::vector< std::unique_ptr< SharedImageSet > > extractAllImages | ( | Data::Kind | kind = Data::UNKNOWN, |
| Data::Modality | modality = Data::NA ) |
Extract all SharedImageSet instances of given kind and modality.
Data::UNKNOWN will match all kinds and Data::NA will match all modalities.
| DataList dataListView | ( | ) | const |
Return a view in form of a DataList onto this OwningDataList.
This can be useful to keep references to the data after passing ownership to another consumer.