OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
WItemSelectionItemTyped< T > Class Template Reference

A derivation of WItemSelection which can store a value of any type. More...

#include <WItemSelectionItemTyped.h>

+ Inheritance diagram for WItemSelectionItemTyped< T >:
+ Collaboration diagram for WItemSelectionItemTyped< T >:

Public Types

typedef std::shared_ptr< WItemSelectionItemTyped< T > > SPtr
 Abbreviation for a shared pointer. More...
 
typedef std::shared_ptr< const WItemSelectionItemTyped< T > > ConstSPtr
 Abbreviation for a const shared pointer. More...
 
typedef T ValueType
 The type of the value stored in here. More...
 
- Public Types inherited from WItemSelectionItem
typedef std::shared_ptr< WItemSelectionItemSPtr
 Abbreviation for a shared pointer. More...
 
typedef std::shared_ptr< const WItemSelectionItemConstSPtr
 Abbreviation for a const shared pointer. More...
 

Public Member Functions

 WItemSelectionItemTyped (T value, std::string name, std::string description="", const char **icon=NULL)
 Constructs a new item with the specified values. More...
 
virtual ~WItemSelectionItemTyped ()
 Destruction. More...
 
const T getValue () const
 Returns the value. More...
 
getValue ()
 Returns the value. More...
 
void setValue (T value)
 Sets a new value, which is associated with this item. More...
 
- Public Member Functions inherited from WItemSelectionItem
 WItemSelectionItem (std::string name, std::string description="", const char **icon=NULL)
 Constructs a new item with the specified values. More...
 
virtual ~WItemSelectionItem ()
 Destruction. More...
 
std::string getName () const
 Returns the name of the item. More...
 
std::string getDescription () const
 The description of the item. More...
 
const char ** getIcon () const
 The icon associated with this item. More...
 
template<typename T >
T * getAs ()
 Dynamic cast of the object, if a derivative of WItemSelectionItem was add to WItemSelection. More...
 
template<typename T >
const T * getAs () const
 Dynamic cast of the object, if a derivative of WItemSelectionItem was add to WItemSelection. More...
 
bool operator== (const WItemSelectionItem &other) const
 Compares this and another item using their names only. More...
 

Static Public Member Functions

static SPtr create (T value, std::string name, std::string description="", const char **icon=NULL)
 Create a instance of the item. More...
 

Private Attributes

m_value
 Value which is stored by this item. More...
 

Additional Inherited Members

- Protected Attributes inherited from WItemSelectionItem
std::string m_name
 Item name. More...
 
std::string m_description
 Item description. More...
 
const char ** m_icon
 Item icon. More...
 

Detailed Description

template<typename T>
class WItemSelectionItemTyped< T >

A derivation of WItemSelection which can store a value of any type.

Note
you can specify a reference type too. When using MyType& as type in this class, you can avoid unnecessary copy operations.
Template Parameters
thetype to encapsulate

Definition at line 43 of file WItemSelectionItemTyped.h.

Member Typedef Documentation

◆ ConstSPtr

template<typename T >
typedef std::shared_ptr< const WItemSelectionItemTyped< T > > WItemSelectionItemTyped< T >::ConstSPtr

Abbreviation for a const shared pointer.

Definition at line 54 of file WItemSelectionItemTyped.h.

◆ SPtr

template<typename T >
typedef std::shared_ptr< WItemSelectionItemTyped< T > > WItemSelectionItemTyped< T >::SPtr

Abbreviation for a shared pointer.

Definition at line 49 of file WItemSelectionItemTyped.h.

◆ ValueType

template<typename T >
typedef T WItemSelectionItemTyped< T >::ValueType

The type of the value stored in here.

Definition at line 59 of file WItemSelectionItemTyped.h.

Constructor & Destructor Documentation

◆ WItemSelectionItemTyped()

template<typename T >
WItemSelectionItemTyped< T >::WItemSelectionItemTyped ( value,
std::string  name,
std::string  description = "",
const char **  icon = NULL 
)
inline

Constructs a new item with the specified values.

Parameters
valueValue which is stored by the item.
nameName of item.
descriptionDescription, can be empty.
iconIcon, can be NULL.

Definition at line 69 of file WItemSelectionItemTyped.h.

◆ ~WItemSelectionItemTyped()

template<typename T >
virtual WItemSelectionItemTyped< T >::~WItemSelectionItemTyped ( )
inlinevirtual

Destruction.

Does NOT delete the icon!

Definition at line 78 of file WItemSelectionItemTyped.h.

Member Function Documentation

◆ create()

template<typename T >
static SPtr WItemSelectionItemTyped< T >::create ( value,
std::string  name,
std::string  description = "",
const char **  icon = NULL 
)
inlinestatic

Create a instance of the item.

This shortens the rather long call which would be needed to create a shared pointer of this class.

Parameters
valuethe value to store in the instance
namethe name of item
descriptionDescription of the item. Can be empty.
iconthe icon of the item. Can be NULL.
Returns
a new instance pointer

Definition at line 92 of file WItemSelectionItemTyped.h.

Referenced by WFiberHandler::addFiber(), WFiberHandler::addFiberAt(), WFiberHandler::createProperties(), WColumnPropertyHandler::initializeSelectionItem(), WMProjectionsAsContext::properties(), WMTemplate::properties(), and WFiberHandler::toggleFiber().

+ Here is the caller graph for this function:

◆ getValue() [1/2]

template<typename T >
T WItemSelectionItemTyped< T >::getValue ( )
inline

Returns the value.

Returns
Value which is stored.

Definition at line 112 of file WItemSelectionItemTyped.h.

References WItemSelectionItemTyped< T >::m_value.

◆ getValue() [2/2]

template<typename T >
const T WItemSelectionItemTyped< T >::getValue ( ) const
inline

Returns the value.

This const version is especially useful when using reference types for T.

Returns
Value which is stored.

Definition at line 102 of file WItemSelectionItemTyped.h.

References WItemSelectionItemTyped< T >::m_value.

◆ setValue()

template<typename T >
void WItemSelectionItemTyped< T >::setValue ( value)
inline

Sets a new value, which is associated with this item.

Parameters
valuenew value which should be stored by this item.

Definition at line 122 of file WItemSelectionItemTyped.h.

References WItemSelectionItemTyped< T >::m_value.

Member Data Documentation

◆ m_value

template<typename T >
T WItemSelectionItemTyped< T >::m_value
private

Value which is stored by this item.

Definition at line 131 of file WItemSelectionItemTyped.h.

Referenced by WItemSelectionItemTyped< T >::getValue(), and WItemSelectionItemTyped< T >::setValue().


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