Instrument Neutral Distributed Interface INDI 2.2.5
indipropertyswitch.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 by Pawel Soja <[email protected]>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#pragma once
20
21#include "indipropertybasic.h"
22#include <map>
23
24namespace INDI
25{
26
27class PropertySwitchPrivate;
28class PropertySwitch: public INDI::PropertyBasic<ISwitch>
29{
30 DECLARE_PRIVATE(PropertySwitch)
31 public:
32 struct NewValues: public std::map<std::string, ISState>
33 {
34 bool contains(const std::string &key, const ISState &state) const
35 {
36 auto it = this->find(key);
37 return it != this->cend() && it->second == state;
38 }
39 };
40
41 public:
42 PropertySwitch(size_t count);
45
46 public:
47 void onNewValues(const std::function<void(const NewValues &)> &callback);
48
49 public:
50 bool update(const ISState states[], const char * const names[], int n);
51 bool isUpdated(const ISState states[], const char * const names[], int n) const;
52 bool hasUpdateCallback() const;
53
54 void fill(
55 const char *device, const char *name, const char *label, const char *group,
56 IPerm permission, ISRule rule, double timeout, IPState state
57 );
58
59 public:
60 void reset();
61 int findOnSwitchIndex() const;
62 std::string findOnSwitchName() const;
64 bool isSwitchOn(const std::string &name) const;
65
66 public:
67 void setRule(ISRule rule);
68
69 public:
70 ISRule getRule() const;
71 const char * getRuleAsString() const;
72};
73
74}
hid_device * device
std::string findOnSwitchName() const
void onNewValues(const std::function< void(const NewValues &)> &callback)
bool isSwitchOn(const std::string &name) const
bool update(const ISState states[], const char *const names[], int n)
const char * getRuleAsString() const
INDI::WidgetViewSwitch * findOnSwitch() const
bool isUpdated(const ISState states[], const char *const names[], int n) const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
Provides generic container for INDI properties.
ISState
Switch state.
Definition indiapi.h:148
IPerm
Permission hint, with respect to client.
Definition indiapi.h:181
IPState
Property state.
Definition indiapi.h:158
ISRule
Switch vector rule hint.
Definition indiapi.h:170
Namespace to encapsulate INDI client, drivers, and mediator classes.
bool contains(const std::string &key, const ISState &state) const