ValueList.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// ValueList.h
//
// Represents a list of items
//
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _ValueList_H
#define _ValueList_H
#include <string>
#include <vector>
#include "Defs.h"
#include "value_classes/Value.h"
class TiXmlElement;
namespace OpenZWave
{
class Msg;
class Node;
class ValueList: public Value
{
public:
struct Item
{
string m_label;
int32 m_value;
};
ValueList( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 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 );
ValueList();
virtual ~ValueList(){}
bool SetByLabel( string const& _label );
bool SetByValue( int32 const _value );
void OnValueRefreshed( int32 const _valueIdx );
// From Value
virtual string const GetAsString() const { return GetItem()->m_label; }
virtual bool SetFromString( string const& _value ) { return SetByLabel( _value ); }
virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
virtual void WriteXML( TiXmlElement* _valueElement );
Item const* GetItem() const;
int32 GetItemIdxByLabel( string const& _label ) const;
int32 GetItemIdxByValue( int32 const _value ) const;
bool GetItemLabels( vector<string>* o_items );
bool GetItemValues( vector<int32>* o_values );
uint8 GetSize()const{ return m_size; }
private:
vector<Item> m_items;
int32 m_valueIdx; // the current index in the m_items vector
int32 m_valueIdxCheck; // the previous index in the m_items vector (used for double-checking spurious value reads)
uint8 m_size;
};
} // namespace OpenZWave
#endif
OpenZWave::ValueList::Item
An item (element) in the list of values.
Definition: ValueList.h:50
OpenZWave::ValueList::Item::m_label
string m_label
Definition: ValueList.h:52
OpenZWave
Definition: Bitfield.h:34
OpenZWave::ValueList::GetSize
uint8 GetSize() const
Definition: ValueList.h:79
OpenZWave::ValueList::Item::m_value
int32 m_value
Definition: ValueList.h:53
Defs.h
OpenZWave::ValueList::SetByLabel
bool SetByLabel(string const &_label)
Definition: ValueList.cpp:242
OpenZWave::ValueList::~ValueList
virtual ~ValueList()
Definition: ValueList.h:58
OpenZWave::Value::OnValueRefreshed
void OnValueRefreshed()
Definition: Value.cpp:412
OpenZWave::ValueList::WriteXML
virtual void WriteXML(TiXmlElement *_valueElement)
Definition: ValueList.cpp:190
int32
signed int int32
Definition: Defs.h:79
OpenZWave::ValueList::ValueList
ValueList()
Definition: ValueList.cpp:72
uint32
unsigned int uint32
Definition: Defs.h:80
OpenZWave::ValueList::SetByValue
bool SetByValue(int32 const _value)
Definition: ValueList.cpp:220
OpenZWave::ValueList::SetFromString
virtual bool SetFromString(string const &_value)
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:87
OpenZWave::ValueList::GetItemIdxByValue
int32 GetItemIdxByValue(int32 const _value) const
Definition: ValueList.cpp:314
OpenZWave::ValueList::GetAsString
virtual string const GetAsString() const
Definition: ValueList.h:66
OpenZWave::ValueList::GetItemIdxByLabel
int32 GetItemIdxByLabel(string const &_label) const
Definition: ValueList.cpp:294
Value.h
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:47
OpenZWave::ValueList::GetItemLabels
bool GetItemLabels(vector< string > *o_items)
Definition: ValueList.cpp:334
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition: ValueID.h:71
OpenZWave::ValueList
List of values sent to/received from a node.
Definition: ValueList.h:45
OpenZWave::ValueList::GetItem
Item const * GetItem() const
Definition: ValueList.cpp:377
uint8
unsigned char uint8
Definition: Defs.h:74
OpenZWave::ValueList::GetItemValues
bool GetItemValues(vector< int32 > *o_values)
Definition: ValueList.cpp:356