OpenZWave Library: ValueList.h Source File

| OpenZWave Library 1.6.0

ValueList.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // ValueList.h
4 //
5 // Represents a list of items
6 //
7 // Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27
28 #ifndef _ValueList_H
29 #define _ValueList_H
30
31 #include <string>
32 #include <vector>
33 #include "Defs.h"
34 #include "value_classes/Value.h"
35
36 class TiXmlElement;
37
38 namespace OpenZWave
39 {
40 class Msg;
41 class Node;
42
46 class ValueList: public Value
47 {
48 public:
51 struct Item
52 {
53 string m_label;
54 int32 m_value;
55 };
56
57 ValueList( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, vector<Item> const& _items, int32 const _valueIdx, uint8 const _pollIntensity, uint8 const _size = 4 );
58 ValueList();
59 virtual ~ValueList(){}
60
61 bool SetByLabel( string const& _label );
62 bool SetByValue( int32 const _value );
63
64 void OnValueRefreshed( int32 const _valueIdx );
65
66 // From Value
67 virtual string const GetAsString() const { return GetItem()->m_label; }
68 virtual bool SetFromString( string const& _value ) { return SetByLabel( _value ); }
69 virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
70 virtual void WriteXML( TiXmlElement* _valueElement );
71
72 Item const* GetItem() const;
73
74 int32 GetItemIdxByLabel( string const& _label ) const;
75 int32 GetItemIdxByValue( int32 const _value ) const;
76
77 bool GetItemLabels( vector<string>* o_items );
78 bool GetItemValues( vector<int32>* o_values );
79
80 uint8 GetSize()const{ return m_size; }
81
82 private:
83 vector<Item> m_items;
84 int32 m_valueIdx; // the current index in the m_items vector
85 int32 m_valueIdxCheck; // the previous index in the m_items vector (used for double-checking spurious value reads)
86 uint8 m_size;
87 };
88
89 } // namespace OpenZWave
90
91 #endif
92
93
94
uint32
unsigned int uint32
Definition: Defs.h:95
OpenZWave::ValueList::GetItemValues
bool GetItemValues(vector< int32 > *o_values)
Definition: ValueList.cpp:392
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition: ValueID.h:81
uint8
unsigned char uint8
Definition: Defs.h:89
OpenZWave::ValueList::GetItemIdxByLabel
int32 GetItemIdxByLabel(string const &_label) const
Definition: ValueList.cpp:330
OpenZWave::ValueList::SetByLabel
bool SetByLabel(string const &_label)
Definition: ValueList.cpp:278
OpenZWave::ValueList::~ValueList
virtual ~ValueList()
Definition: ValueList.h:59
OpenZWave::ValueList::SetFromString
virtual bool SetFromString(string const &_value)
Definition: ValueList.h:68
int32
signed int int32
Definition: Defs.h:94
OpenZWave::ValueList::Item::m_value
int32 m_value
Definition: ValueList.h:54
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:49
OpenZWave::Value::OnValueRefreshed
void OnValueRefreshed()
Definition: Value.cpp:405
OpenZWave::ValueList::SetByValue
bool SetByValue(int32 const _value)
Definition: ValueList.cpp:256
OpenZWave::ValueList::GetAsString
virtual string const GetAsString() const
Definition: ValueList.h:67
OpenZWave::ValueList::ReadXML
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition: ValueList.cpp:96
OpenZWave::ValueList::ValueList
ValueList()
Definition: ValueList.cpp:80
OpenZWave::ValueList::GetItem
Item const * GetItem() const
Definition: ValueList.cpp:413
OpenZWave::ValueList::Item
An item (element) in the list of values.
Definition: ValueList.h:52
OpenZWave::ValueList::Item::m_label
string m_label
Definition: ValueList.h:53
OpenZWave::ValueList::GetItemLabels
bool GetItemLabels(vector< string > *o_items)
Definition: ValueList.cpp:370
Defs.h
OpenZWave::ValueList::GetSize
uint8 GetSize() const
Definition: ValueList.h:80
OpenZWave::ValueList::WriteXML
virtual void WriteXML(TiXmlElement *_valueElement)
Definition: ValueList.cpp:226
OpenZWave::ValueList::GetItemIdxByValue
int32 GetItemIdxByValue(int32 const _value) const
Definition: ValueList.cpp:350
Value.h
uint16
unsigned short uint16
Definition: Defs.h:92
OpenZWave
Definition: Bitfield.h:35
OpenZWave::ValueList
List of values sent to/received from a node.
Definition: ValueList.h:47