OpenWalnut
1.5.0dev
|
A class containing a list of named items. More...
#include <WItemSelection.h>
Public Types | |
typedef std::shared_ptr< WItemSelection > | SPtr |
Convenience typedef for a std::shared_ptr< WItemSelection > More... | |
typedef std::shared_ptr< const WItemSelection > | ConstSPtr |
Convenience typedef for a std::shared_ptr< const WItemSelection > More... | |
Public Types inherited from WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > > | |
typedef S::const_iterator | ConstIterator |
A typedef for the correct const iterator useful to traverse this sequence container. More... | |
typedef S::iterator | Iterator |
A typedef for the correct iterator to traverse this sequence container. More... | |
typedef S::value_type | value_type |
The type of the elements. More... | |
Public Types inherited from WSharedObject< T > | |
typedef T | ValueT |
The type protected by this shared object class. More... | |
typedef std::shared_ptr< WSharedObjectTicketRead< T > > | ReadTicket |
Type for read tickets. More... | |
typedef std::shared_ptr< WSharedObjectTicketWrite< T > > | WriteTicket |
Type for write tickets. More... | |
typedef std::shared_ptr< WSharedObject< T > > | SPtr |
Shared pointer abbreviation. More... | |
typedef std::shared_ptr< WSharedObject< T > > | ConstSPtr |
Const shared ptr abbreviation. More... | |
Public Member Functions | |
WItemSelection () | |
Default constructor. More... | |
virtual | ~WItemSelection () |
Destructor. More... | |
virtual WItemSelector | getSelectorAll () |
Creates an default selection (all items selected). More... | |
virtual WItemSelector | getSelectorNone () |
Creates an default selection (no items selected). More... | |
virtual WItemSelector | getSelectorFirst () |
Creates an default selection (first item selected). More... | |
virtual WItemSelector | getSelectorLast () |
Creates an default selection (last item selected). More... | |
virtual WItemSelector | getSelector (size_t item) |
Creates an default selection (a specified items selected). More... | |
void | addItem (std::string name, std::string description="", const char **icon=NULL) |
Convenience method to add a new item. More... | |
void | addItem (std::shared_ptr< WItemSelectionItem > item) |
Method to add a new item, which can be derived from WItemSelectionItem. More... | |
Public Member Functions inherited from WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > > | |
WSharedSequenceContainer () | |
Default constructor. More... | |
virtual | ~WSharedSequenceContainer () |
Destructor. More... | |
void | push_back (const typename S::value_type &x) |
Adds a new element at the end of the container. More... | |
void | push_front (const typename S::value_type &x) |
Adds a new element at the beginning of the container. More... | |
void | pop_back () |
Removes an element from the end. More... | |
void | unique_push_back (const typename S::value_type &x) |
Add the element only if it is not inside the container until now. More... | |
void | unique_push_front (const typename S::value_type &x) |
Add the element only if it is not inside the container until now. More... | |
void | clear () |
Clears the container. More... | |
size_t | size () const |
The size of the container. More... | |
S::value_type & | operator[] (size_t n) |
Get item at position n. More... | |
const S::value_type & | operator[] (size_t n) const |
Get item at position n. More... | |
S::value_type & | at (size_t n) |
Get item at position n. More... | |
const S::value_type & | at (size_t n) const |
Get item at position n. More... | |
void | remove (const typename S::value_type &element) |
Searches and removes the specified element. More... | |
WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator | erase (typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator position) |
Erase the element at the specified position. More... | |
WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator | erase (typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator first, typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator last) |
Erase the specified range of elements. More... | |
void | replace (const typename S::value_type &oldValue, const typename S::value_type &newValue) |
Replaces the specified old value by a new one. More... | |
size_t | count (const value_type &value) |
Counts the number of occurrences of the specified value inside the container. More... | |
void | sort (Comparator comp) |
Resorts the container using the specified comparator from its begin to its end. More... | |
void | sort (typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator first, typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator last, Comparator comp) |
Resorts the container using the specified comparator between [first,last) in ascending order. More... | |
void | stableSort (Comparator comp) |
Resorts the container using the specified comparator from its begin to its end. More... | |
void | stableSort (typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator first, typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator last, Comparator comp) |
Resorts the container using the specified comparator between [first,last) in ascending order. More... | |
WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator | find (typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator first, typename WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::Iterator last, const typename S::value_type &value) |
Searches the specified value in the range [first,last). More... | |
WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::ConstIterator | find (const typename S::value_type &value) |
Searches the specified value in the range [begin,end). More... | |
Public Member Functions inherited from WSharedObject< T > | |
WSharedObject () | |
Default constructor. More... | |
virtual | ~WSharedObject () |
Destructor. More... | |
ReadTicket | getReadTicket () const |
Returns a ticket to get read access to the contained data. More... | |
WriteTicket | getWriteTicket (bool suppressNotify=false) const |
Returns a ticket to get write access to the contained data. More... | |
std::shared_ptr< WCondition > | getChangeCondition () const |
This condition fires whenever the encapsulated object changed. More... | |
Static Public Member Functions | |
static std::shared_ptr< WItemSelectionItem > | Item (std::string name, std::string description="", const char **icon=NULL) |
Convenience method to create a new item. More... | |
Friends | |
class | WItemSelector |
for proper locking and unlocking More... | |
Additional Inherited Members | |
Protected Attributes inherited from WSharedObject< T > | |
T | m_object |
The object wrapped by this class. More... | |
std::shared_ptr< std::shared_mutex > | m_lock |
The lock to ensure thread safe access. More... | |
std::shared_ptr< WCondition > | m_changeCondition |
This condition set fires whenever the contained object changes. More... | |
A class containing a list of named items.
It is mainly a container for an std::vector but with the difference that there can be so called Selectors which are able to select some subset of the item set. This is especially useful in properties where item selection is needed. The class is kept very restrictive to keep the interface clean and sleek and to keep the item set consistent among several threads. So please do not implement any function that might change the item list, use the provided ones. If the item list changes, existing selectors get invalid automatically using the change condition of the inherited WSharedSequenceContainer.
Definition at line 48 of file WItemSelection.h.
typedef std::shared_ptr< const WItemSelection > WItemSelection::ConstSPtr |
Convenience typedef for a std::shared_ptr< const WItemSelection >
Definition at line 61 of file WItemSelection.h.
typedef std::shared_ptr< WItemSelection > WItemSelection::SPtr |
Convenience typedef for a std::shared_ptr< WItemSelection >
Definition at line 56 of file WItemSelection.h.
WItemSelection::WItemSelection | ( | ) |
Default constructor.
Definition at line 35 of file WItemSelection.cpp.
|
virtual |
Destructor.
Definition at line 41 of file WItemSelection.cpp.
void WItemSelection::addItem | ( | std::shared_ptr< WItemSelectionItem > | item | ) |
Method to add a new item, which can be derived from WItemSelectionItem.
item | WItemSelectionItem or derivation which should be add. |
Definition at line 107 of file WItemSelection.cpp.
References WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::push_back().
void WItemSelection::addItem | ( | std::string | name, |
std::string | description = "" , |
||
const char ** | icon = NULL |
||
) |
Convenience method to add a new item.
name | name of the item |
description | the description, can be empty |
icon | the icon, can be NULL |
Definition at line 102 of file WItemSelection.cpp.
References WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::push_back().
|
virtual |
Creates an default selection (a specified items selected).
The selector gets invalid if another item is added.
item | the item to select. |
Definition at line 89 of file WItemSelection.cpp.
References WSharedObject< T >::getReadTicket(), and WItemSelector.
|
virtual |
Creates an default selection (all items selected).
The selector gets invalid if another item is added.
Definition at line 46 of file WItemSelection.cpp.
References WSharedObject< T >::getReadTicket(), WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >::size(), and WItemSelector.
|
virtual |
Creates an default selection (first item selected).
The selector gets invalid if another item is added.
Definition at line 65 of file WItemSelection.cpp.
References WSharedObject< T >::getReadTicket(), and WItemSelector.
|
virtual |
Creates an default selection (last item selected).
The selector gets invalid if another item is added.
Definition at line 77 of file WItemSelection.cpp.
References WSharedObject< T >::getReadTicket(), and WItemSelector.
|
virtual |
Creates an default selection (no items selected).
The selector gets invalid if another item is added.
Definition at line 58 of file WItemSelection.cpp.
References WSharedObject< T >::getReadTicket(), and WItemSelector.
|
inlinestatic |
Convenience method to create a new item.
name | name of the item |
description | the description, can be empty |
icon | the icon, can be NULL |
Definition at line 119 of file WItemSelection.h.
|
friend |
for proper locking and unlocking
Definition at line 51 of file WItemSelection.h.
Referenced by getSelector(), getSelectorAll(), getSelectorFirst(), getSelectorLast(), and getSelectorNone().