DS2482-RK
Public Member Functions | Protected Attributes
DS2482DeviceList Class Reference

Holds an array of DS2482Device objects. More...

#include <DS2482-RK.h>

Inheritance diagram for DS2482DeviceList:
DS2482DeviceListStatic< SIZE >

Public Member Functions

 DS2482DeviceList (DS2482Device *devices, size_t deviceMax)
 Constructs a DS2482DeviceList object with an array of DS2482Device objects.
 
virtual ~DS2482DeviceList ()
 Destructor for DS2482DeviceList.
 
bool addAddress (const DS24821WireAddress &addr)
 Adds a DS24821WireAddress to the device list. More...
 
void clear ()
 Clears add of the objects in the array.
 
void clearValid ()
 Clears all of the valid values in the array. More...
 
DS24821WireAddress getAddressByIndex (size_t ii)
 Gets the 1-wire address of a device in list by index. More...
 
DS2482DevicegetDeviceByIndex (size_t ii)
 Gets the DS2482Device of a device in list by index. More...
 
const DS2482DevicegetDeviceByIndex (size_t ii) const
 Gets the DS2482Device of a device in list by index. More...
 
size_t getDeviceCount ()
 Returns the number of devices in the list (devices that have been added) More...
 
size_t getDeviceMax ()
 Returns the maximum number of devices that can be added, based on the size of the array. More...
 

Protected Attributes

DS2482Devicedevices
 The array of device objects.
 
size_t deviceCount
 The number of devices currently in the list (0 = none, 1 = one, ...)
 
size_t deviceMax
 The maximum number of objects in the array.
 

Detailed Description

Holds an array of DS2482Device objects.

Normally you will use DS2482DeviceListStatic, below, instead of instantiating this object directly.

This class does not allocate memory; you pass in a buffer and length and it keeps track of the number of devices in the list. Note that deviceMax is in number of DS2482Device objects; the actual size in bytes is 16 times that.

Member Function Documentation

◆ addAddress()

bool DS2482DeviceList::addAddress ( const DS24821WireAddress addr)

Adds a DS24821WireAddress to the device list.

Parameters
addrThe 1-wire address to add. addr is copied.
Returns
true if the address was added or false if the device list is full.

◆ clearValid()

void DS2482DeviceList::clearValid ( )

Clears all of the valid values in the array.

This is done before reading temperatures using DS24821GetTemperatureForListCommand.

◆ getAddressByIndex()

DS24821WireAddress DS2482DeviceList::getAddressByIndex ( size_t  ii)
inline

Gets the 1-wire address of a device in list by index.

Parameters
iiThe index to retrieve (0 is the first element)
Returns
The address as a DS24821WireAddress (copied)

◆ getDeviceByIndex() [1/2]

DS2482Device& DS2482DeviceList::getDeviceByIndex ( size_t  ii)
inline

Gets the DS2482Device of a device in list by index.

Parameters
iiThe index to retrieve (0 is the first element)
Returns
The DS2482Device object (the actual object reference, not copied)

◆ getDeviceByIndex() [2/2]

const DS2482Device& DS2482DeviceList::getDeviceByIndex ( size_t  ii) const
inline

Gets the DS2482Device of a device in list by index.

Parameters
iiThe index to retrieve (0 is the first element)
Returns
The DS2482Device object (the actual object reference, not copied) as a const object that can't be modified.

Note that DS2482Device supports the copy operator and copy constructor so it's easy to make your own copy of it.

◆ getDeviceCount()

size_t DS2482DeviceList::getDeviceCount ( )
inline

Returns the number of devices in the list (devices that have been added)

Returns
The number of added devices (0 = none, 1 = one, ...)

◆ getDeviceMax()

size_t DS2482DeviceList::getDeviceMax ( )
inline

Returns the maximum number of devices that can be added, based on the size of the array.

Returns
The maximum number of devices that can be added

If getDeviceCount() == getDeviceMax() then the list is full and no more can be added.


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