OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Attributes | List of all members
WItemSelectionItem Class Reference

Class for keeping a single named item in a WItemSelection. More...

#include <WItemSelectionItem.h>

+ Inheritance diagram for WItemSelectionItem:
+ Collaboration diagram for WItemSelectionItem:

Public Types

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

 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...
 

Protected Attributes

std::string m_name
 Item name. More...
 
std::string m_description
 Item description. More...
 
const char ** m_icon
 Item icon. More...
 

Detailed Description

Class for keeping a single named item in a WItemSelection.

Definition at line 35 of file WItemSelectionItem.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WItemSelectionItem > WItemSelectionItem::ConstSPtr

Abbreviation for a const shared pointer.

Definition at line 46 of file WItemSelectionItem.h.

◆ SPtr

typedef std::shared_ptr< WItemSelectionItem > WItemSelectionItem::SPtr

Abbreviation for a shared pointer.

Definition at line 41 of file WItemSelectionItem.h.

Constructor & Destructor Documentation

◆ WItemSelectionItem()

WItemSelectionItem::WItemSelectionItem ( std::string  name,
std::string  description = "",
const char **  icon = NULL 
)

Constructs a new item with the specified values.

Parameters
nameName of item.
descriptionDescription, can be empty.
iconIcon, can be NULL.

Definition at line 29 of file WItemSelectionItem.cpp.

◆ ~WItemSelectionItem()

WItemSelectionItem::~WItemSelectionItem ( )
virtual

Destruction.

Does NOT delete the icon!

Definition at line 37 of file WItemSelectionItem.cpp.

Member Function Documentation

◆ getAs() [1/2]

template<typename T >
T* WItemSelectionItem::getAs ( )
inline

Dynamic cast of the object, if a derivative of WItemSelectionItem was add to WItemSelection.

Returns
Returns the converted item of new type T or 0 if a conversion is not possible.

Definition at line 89 of file WItemSelectionItem.h.

◆ getAs() [2/2]

template<typename T >
const T* WItemSelectionItem::getAs ( ) const
inline

Dynamic cast of the object, if a derivative of WItemSelectionItem was add to WItemSelection.

Returns
Returns the converted item of new type T or 0 if a conversion is not possible.

Definition at line 100 of file WItemSelectionItem.h.

◆ getDescription()

std::string WItemSelectionItem::getDescription ( ) const

The description of the item.

Returns
the description

Definition at line 47 of file WItemSelectionItem.cpp.

References m_description.

◆ getIcon()

const char ** WItemSelectionItem::getIcon ( ) const

The icon associated with this item.

Can be NULL.

Returns
the icon, might be NULL.

Definition at line 52 of file WItemSelectionItem.cpp.

References m_icon.

◆ getName()

std::string WItemSelectionItem::getName ( ) const

Returns the name of the item.

Returns
the name

Definition at line 42 of file WItemSelectionItem.cpp.

References m_name.

◆ operator==()

bool WItemSelectionItem::operator== ( const WItemSelectionItem other) const

Compares this and another item using their names only.

Parameters
otherthe second to compare the this one with
Returns
true if the names are equal.

Definition at line 57 of file WItemSelectionItem.cpp.

References m_name.

Member Data Documentation

◆ m_description

std::string WItemSelectionItem::m_description
protected

Item description.

Definition at line 123 of file WItemSelectionItem.h.

Referenced by getDescription().

◆ m_icon

const char** WItemSelectionItem::m_icon
protected

Item icon.

Definition at line 128 of file WItemSelectionItem.h.

Referenced by getIcon().

◆ m_name

std::string WItemSelectionItem::m_name
protected

Item name.

Definition at line 118 of file WItemSelectionItem.h.

Referenced by getName(), and operator==().


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