Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
kome::core::RangeListSelector Class Reference

selector class More...

#include <RangeListSelector.h>

Inheritance diagram for kome::core::RangeListSelector:
Inheritance graph
[legend]
Collaboration diagram for kome::core::RangeListSelector:
Collaboration graph
[legend]

Public Types

enum  RangeType { RANGE_INDEX, RANGE_INT_VALUE, RANGE_DOUBLE_VALUE }
 range type
 

Public Member Functions

 RangeListSelector (const RangeList::DefaultType dflt=RangeList::DEFAULT_NONE, const RangeType type=RANGE_INDEX)
 constructor More...
 
virtual ~RangeListSelector ()
 destructor
 
RangeListgetRangeList ()
 gets ranges list object More...
 
- Public Member Functions inherited from kome::core::Selector
 Selector ()
 constructor
 
virtual ~Selector ()
 destructor
 
void clearItems ()
 clear items
 
void addItem (const char *name)
 adds item More...
 
void addItem (const char *name, const char *value)
 adds item More...
 
unsigned int getNumberOfItems ()
 gets the number of items More...
 
const char * getItemName (const unsigned int index)
 gets item name More...
 
const char * getItemValue (const unsigned int index)
 gets item value More...
 
bool isSelected (const unsigned int index)
 gets selection flag value More...
 
int getSelection ()
 [in] gets selected item More...
 
bool select ()
 selects item More...
 

Protected Member Functions

virtual bool onSelect (const unsigned int num, const char **items, const char **values, bool *selected)
 This method is called by select method. (override method) More...
 

Protected Attributes

RangeType m_type
 
RangeList m_ranges
 
- Protected Attributes inherited from kome::core::Selector
std::vector< std::pair
< std::string, std::string > > 
m_items
 
std::vector< bool > m_selected
 
int m_sel
 

Detailed Description

selector class

Definition at line 27 of file RangeListSelector.h.

Constructor & Destructor Documentation

kome::core::RangeListSelector::RangeListSelector ( const RangeList::DefaultType  dflt = RangeList::DEFAULT_NONE,
const RangeType  type = RANGE_INDEX 
)

constructor

Parameters
[in]dfltdefault data selection type
[in]typerange type

Definition at line 28 of file RangeListSelector.cpp.

29  : m_type( type ), m_ranges( dflt ) {
30 }

Member Function Documentation

RangeList & kome::core::RangeListSelector::getRangeList ( )

gets ranges list object

Returns
range list

Definition at line 37 of file RangeListSelector.cpp.

37  {
38  return m_ranges;
39 }
bool kome::core::RangeListSelector::onSelect ( const unsigned int  num,
const char **  items,
const char **  values,
bool *  selected 
)
protectedvirtual

This method is called by select method. (override method)

Parameters
[in]numthe number of items
[in]itemsthe array of item names
[in]valuesthe array of item values
[out]selectedthe array to store selected flags
Returns
If true, the selection was normally done.

Implements kome::core::Selector.

Definition at line 42 of file RangeListSelector.cpp.

47  {
48  // each items
49  for( unsigned int i = 0; i < num; i++ ) {
50  // get selected
51  bool sel = false;
52 
53  if( m_type == RANGE_INDEX ) { // index
54  sel = m_ranges.checkIntValue( i );
55  }
56  else if( m_type == RANGE_INT_VALUE ) { // integer value
57  int v = int();
58  if( isint( values[ i ], 10, &v ) ) {
59  sel = m_ranges.checkIntValue( v );
60  }
61  }
62  else if( m_type == RANGE_DOUBLE_VALUE ) { // double value
63  double v = double();
64  if( isdouble( values[ i ], &v ) ) {
65  sel = m_ranges.checkDoubleValue( v );
66  }
67  }
68 
69  selected[ i ] = sel;
70  }
71 
72  return true;
73 }
bool isdouble(const char *s, double *val)
judge whether sutisfied character string shows real number.
bool checkIntValue(const int val)
checks integer vlaue
Definition: RangeList.cpp:100
bool isint(const char *s, const int radix, int *val)
judge whether sutisfied character string shows integer number.
bool checkDoubleValue(const double val)
checks double value
Definition: RangeList.cpp:117

Here is the call graph for this function:

Member Data Documentation

RangeList kome::core::RangeListSelector::m_ranges
protected

range list

Definition at line 65 of file RangeListSelector.h.

RangeType kome::core::RangeListSelector::m_type
protected

range type

Definition at line 62 of file RangeListSelector.h.


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