| 1 | /******************************************************************************* |
| 2 | Copyright(c) 2011 Jasem Mutlaq. All rights reserved. |
| 3 | 2022 Pawel Soja <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License version 2 as published by the Free Software Foundation. |
| 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 | Library General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Library General Public License |
| 15 | along with this library; see the file COPYING.LIB. If not, write to |
| 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | Boston, MA 02110-1301, USA. |
| 18 | *******************************************************************************/ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "indibase.h"cxx . . $ `<file>/libs/indidevice/indibase.h`/ |
| 23 | #include "indiutility.h"cxx . . $ `<file>/libs/indidevice/indiutility.h`/ |
| 24 | |
| 25 | #include "indipropertyview.h"cxx . . $ `<file>/libs/indidevice/property/indipropertyview.h`/ |
| 26 | |
| 27 | #include <memory> |
| 28 | #include <cstdarg> |
| 29 | #include <functional> |
| 30 | |
| 31 | #define INDI_PROPERTY_BACKWARD_COMPATIBILEcxx . . $ `libs/indidevice/property/indiproperty.h:31:9`! |
| 32 | namespace INDIcxx . . $ INDI/ |
| 33 | { |
| 34 | class BaseDevicecxx . . $ INDI/BaseDevice#; |
| 35 | class PropertyNumbercxx . . $ INDI/PropertyNumber#; |
| 36 | class PropertyTextcxx . . $ INDI/PropertyText#; |
| 37 | class PropertySwitchcxx . . $ INDI/PropertySwitch#; |
| 38 | class PropertyLightcxx . . $ INDI/PropertyLight#; |
| 39 | class PropertyBlobcxx . . $ INDI/PropertyBlob#; |
| 40 | /** |
| 41 | * \class INDI::Property |
| 42 | \brief Provides generic container for INDI properties |
| 43 | |
| 44 | \author Jasem Mutlaq |
| 45 | */ |
| 46 | class PropertyPrivatecxx . . $ INDI/PropertyPrivate#; |
| 47 | class Propertycxx . . $ INDI/Property# |
| 48 | { |
| 49 | DECLARE_PRIVATEcxx . . $ getPtrHelper(7b668a8cbe9c1c99).(Property) |
| 50 | public: |
| 51 | Propertycxx . . $ INDI/Property#Property(49f6e7a06ebc5aa8).(); |
| 52 | ~cxx . . $ INDI/Property#`~Property`(49f6e7a06ebc5aa8).Propertycxx . . $ INDI/Property#(); |
| 53 | |
| 54 | public: |
| 55 | Propertycxx . . $ INDI/Property#Property(c8d9f698d3ab1fef).(INDIcxx . . $ INDI/::PropertyNumbercxx . . $ INDI/PropertyNumber# property); |
| 56 | Propertycxx . . $ INDI/Property#Property(6c109fdd43e6e4).(INDIcxx . . $ INDI/::PropertyTextcxx . . $ INDI/PropertyText# property); |
| 57 | Propertycxx . . $ INDI/Property#Property(e11d2fe477b6194b).(INDIcxx . . $ INDI/::PropertySwitchcxx . . $ INDI/PropertySwitch# property); |
| 58 | Propertycxx . . $ INDI/Property#Property(5fdb179365e0862f).(INDIcxx . . $ INDI/::PropertyLightcxx . . $ INDI/PropertyLight# property); |
| 59 | Propertycxx . . $ INDI/Property#Property(2c3fb4c0ac5a2883).(INDIcxx . . $ INDI/::PropertyBlobcxx . . $ INDI/PropertyBlob# property); |
| 60 | |
| 61 | #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILEcxx . . $ `libs/indidevice/property/indiproperty.h:31:9`! |
| 62 | public: |
| 63 | Propertycxx . . $ INDI/Property#Property(cbe224b2eb909406).(INumberVectorPropertycxx . . $ INumberVectorProperty# *property); |
| 64 | Propertycxx . . $ INDI/Property#Property(c4ae785439b278d0).(ITextVectorPropertycxx . . $ ITextVectorProperty# *property); |
| 65 | Propertycxx . . $ INDI/Property#Property(937b9cd86f7e998c).(ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# *property); |
| 66 | Propertycxx . . $ INDI/Property#Property(8df8cd29d71f277a).(ILightVectorPropertycxx . . $ ILightVectorProperty# *property); |
| 67 | Propertycxx . . $ INDI/Property#Property(158ea0778754bb38).(IBLOBVectorPropertycxx . . $ IBLOBVectorProperty# *property); |
| 68 | |
| 69 | public: |
| 70 | Propertycxx . . $ INDI/Property#Property(c2ff22d72e455b11).(INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<INumbercxx . . $ INumber#> *property); |
| 71 | Propertycxx . . $ INDI/Property#Property(7dbbc2a80f6eb5ec).(INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ITextcxx . . $ IText#> *property); |
| 72 | Propertycxx . . $ INDI/Property#Property(f2d965234d3eff19).(INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ISwitchcxx . . $ ISwitch#> *property); |
| 73 | Propertycxx . . $ INDI/Property#Property(8b781eb44eaf2174).(INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ILightcxx . . $ ILight#> *property); |
| 74 | Propertycxx . . $ INDI/Property#Property(28d88538192f8361).(INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<IBLOBcxx . . $ IBLOB#> *property); |
| 75 | |
| 76 | #endif |
| 77 | public: |
| 78 | void setPropertycxx . . $ INDI/Property#setProperty(5d22bdacc48458e8).(void *); |
| 79 | void setTypecxx . . $ INDI/Property#setType(cc8d582bb310a03).(INDI_PROPERTY_TYPEcxx . . $ INDI_PROPERTY_TYPE# t); |
| 80 | void setRegisteredcxx . . $ INDI/Property#setRegistered(b45ddcbc8423892c).(bool r); |
| 81 | void setDynamiccxx . . $ INDI/Property#setDynamic(b45ddcbc8423892c).(bool d); |
| 82 | |
| 83 | INDI_DEPRECATEDcxx . . $ `libs/indimacros.h:149:10`!("Use setBaseDevice(BaseDevice).") |
| 84 | void setBaseDevicecxx . . $ INDI/Property#setBaseDevice(b76ca60cd6b5bc98).(BaseDevicecxx . . $ INDI/BaseDevice# *idp); |
| 85 | |
| 86 | void setBaseDevicecxx . . $ INDI/Property#setBaseDevice(55bbe0148972d57).(BaseDevicecxx . . $ INDI/BaseDevice# device); |
| 87 | |
| 88 | public: |
| 89 | void *getPropertycxx . . $ INDI/Property#getProperty(45a5c5ac6be858a8).() const; |
| 90 | INDI_PROPERTY_TYPEcxx . . $ INDI_PROPERTY_TYPE# getTypecxx . . $ INDI/Property#getType(81b416eae84427e7).() const; |
| 91 | const char *getTypeAsStringcxx . . $ INDI/Property#getTypeAsString(a9f41ea0e82d88cf).() const; |
| 92 | bool getRegisteredcxx . . $ INDI/Property#getRegistered(50ce9a9e25b4a850).() const; |
| 93 | bool isDynamiccxx . . $ INDI/Property#isDynamic(50ce9a9e25b4a850).() const; |
| 94 | BaseDevicecxx . . $ INDI/BaseDevice# getBaseDevicecxx . . $ INDI/Property#getBaseDevice(210b86d7ec2e848e).() const; |
| 95 | |
| 96 | public: // Convenience Functions |
| 97 | void setNamecxx . . $ INDI/Property#setName(85c52e162fed56f9).(const char *name); |
| 98 | void setLabelcxx . . $ INDI/Property#setLabel(85c52e162fed56f9).(const char *label); |
| 99 | void setGroupNamecxx . . $ INDI/Property#setGroupName(85c52e162fed56f9).(const char *groupName); |
| 100 | void setDeviceNamecxx . . $ INDI/Property#setDeviceName(85c52e162fed56f9).(const char *deviceName); |
| 101 | void setTimestampcxx . . $ INDI/Property#setTimestamp(85c52e162fed56f9).(const char *timestamp); |
| 102 | void setStatecxx . . $ INDI/Property#setState(ee719c9a0415d7f7).(IPStatecxx . . $ IPState# state); |
| 103 | void setPermissioncxx . . $ INDI/Property#setPermission(bc7e9c04cd4ce0c1).(IPermcxx . . $ IPerm# permission); |
| 104 | void setTimeoutcxx . . $ INDI/Property#setTimeout(ba8836b59fb42830).(double timeout); |
| 105 | |
| 106 | public: // Convenience Functions |
| 107 | const char *getNamecxx . . $ INDI/Property#getName(a9f41ea0e82d88cf).() const; |
| 108 | const char *getLabelcxx . . $ INDI/Property#getLabel(a9f41ea0e82d88cf).() const; |
| 109 | const char *getGroupNamecxx . . $ INDI/Property#getGroupName(a9f41ea0e82d88cf).() const; |
| 110 | const char *getDeviceNamecxx . . $ INDI/Property#getDeviceName(a9f41ea0e82d88cf).() const; |
| 111 | const char *getTimestampcxx . . $ INDI/Property#getTimestamp(a9f41ea0e82d88cf).() const; |
| 112 | IPStatecxx . . $ IPState# getStatecxx . . $ INDI/Property#getState(4693a3a3becca828).() const; |
| 113 | const char *getStateAsStringcxx . . $ INDI/Property#getStateAsString(a9f41ea0e82d88cf).() const; |
| 114 | IPermcxx . . $ IPerm# getPermissioncxx . . $ INDI/Property#getPermission(f8f84b696517e164).() const; |
| 115 | |
| 116 | public: |
| 117 | bool isEmptycxx . . $ INDI/Property#isEmpty(50ce9a9e25b4a850).() const; |
| 118 | bool isValidcxx . . $ INDI/Property#isValid(50ce9a9e25b4a850).() const; |
| 119 | |
| 120 | bool isNameMatchcxx . . $ INDI/Property#isNameMatch(7d4bdb1abc417636).(const char *otherName) const; |
| 121 | bool isNameMatchcxx . . $ INDI/Property#isNameMatch(13a55b95a0133754).(const stdcxx . . $ std/::stringcxx . . $ std/string# &otherName) const; |
| 122 | |
| 123 | bool isLabelMatchcxx . . $ INDI/Property#isLabelMatch(7d4bdb1abc417636).(const char *otherLabel) const; |
| 124 | bool isLabelMatchcxx . . $ INDI/Property#isLabelMatch(13a55b95a0133754).(const stdcxx . . $ std/::stringcxx . . $ std/string# &otherLabel) const; |
| 125 | |
| 126 | public: |
| 127 | void onUpdatecxx . . $ INDI/Property#onUpdate(c4562eec6a87e510).(const stdcxx . . $ std/::functioncxx . . $ std/function#<void()> &callback); |
| 128 | |
| 129 | public: |
| 130 | void emitUpdatecxx . . $ INDI/Property#emitUpdate(49f6e7a06ebc5aa8).(); |
| 131 | bool hasUpdateCallbackcxx . . $ INDI/Property#hasUpdateCallback(50ce9a9e25b4a850).() const; |
| 132 | |
| 133 | public: |
| 134 | void savecxx . . $ INDI/Property#save(e682089247c2ee8c).(FILEcxx . . $ FILE# *fp) const; |
| 135 | |
| 136 | public: |
| 137 | void applycxx . . $ INDI/Property#apply(99ceeb43fa8db937).(const char *format, ...) const ATTRIBUTE_FORMAT_PRINTFcxx . . $ `libs/indicore/indidevapi.h:137:11`!(2, 3); |
| 138 | void definecxx . . $ INDI/Property#define(99ceeb43fa8db937).(const char *format, ...) const ATTRIBUTE_FORMAT_PRINTFcxx . . $ `libs/indicore/indidevapi.h:137:11`!(2, 3); |
| 139 | |
| 140 | void applycxx . . $ INDI/Property#apply(83f5f38750778ac8).() const |
| 141 | { |
| 142 | applycxx . . $ INDI/Property#apply(99ceeb43fa8db937).(nullptr); |
| 143 | } |
| 144 | void definecxx . . $ INDI/Property#define(83f5f38750778ac8).() const |
| 145 | { |
| 146 | definecxx . . $ INDI/Property#define(99ceeb43fa8db937).(nullptr); |
| 147 | } |
| 148 | |
| 149 | public: |
| 150 | #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILEcxx . . $ `libs/indidevice/property/indiproperty.h:31:9`! |
| 151 | INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<INumbercxx . . $ INumber#> *getNumbercxx . . $ INDI/Property#getNumber(ef1caeab3a3ec43f).() const; |
| 152 | INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ITextcxx . . $ IText#> *getTextcxx . . $ INDI/Property#getText(597479030e8456da).() const; |
| 153 | INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ISwitchcxx . . $ ISwitch#> *getSwitchcxx . . $ INDI/Property#getSwitch(a6aa53ccff67cea7).() const; |
| 154 | INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ILightcxx . . $ ILight#> *getLightcxx . . $ INDI/Property#getLight(5771a6f4cdf19338).() const; |
| 155 | INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<IBLOBcxx . . $ IBLOB#> *getBLOBcxx . . $ INDI/Property#getBLOB(44b9300d803ba00c).() const; |
| 156 | #endif |
| 157 | |
| 158 | public: |
| 159 | #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILEcxx . . $ `libs/indidevice/property/indiproperty.h:31:9`! |
| 160 | INDIcxx . . $ INDI/::Propertycxx . . $ INDI/Property#* operatorcxx . . $ INDI/Property#`operator->`(cb204bb0d37236f4).->(); |
| 161 | const INDIcxx . . $ INDI/::Propertycxx . . $ INDI/Property#* operatorcxx . . $ INDI/Property#`operator->`(e6c2859d0d2f5873).->() const; |
| 162 | |
| 163 | operatorcxx . . $ INDI/Property#`operator INDI::Property *`(cb204bb0d37236f4). INDIcxx . . $ INDI/::Propertycxx . . $ INDI/Property# *(); |
| 164 | operatorcxx . . $ INDI/Property#`operator const INDI::Property *`(e6c2859d0d2f5873). const INDIcxx . . $ INDI/::Propertycxx . . $ INDI/Property# *() const; |
| 165 | |
| 166 | operatorcxx . . $ INDI/Property#`operator INDI::PropertyView<_INumber> *`(ef1caeab3a3ec43f). INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<INumbercxx . . $ INumber#> *() const { return getNumbercxx . . $ INDI/Property#getNumber(ef1caeab3a3ec43f).(); } |
| 167 | operatorcxx . . $ INDI/Property#`operator INDI::PropertyView<_IText> *`(597479030e8456da). INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ITextcxx . . $ IText#> *() const { return getTextcxx . . $ INDI/Property#getText(597479030e8456da).(); } |
| 168 | operatorcxx . . $ INDI/Property#`operator INDI::PropertyView<_ISwitch> *`(a6aa53ccff67cea7). INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ISwitchcxx . . $ ISwitch#> *() const { return getSwitchcxx . . $ INDI/Property#getSwitch(a6aa53ccff67cea7).(); } |
| 169 | operatorcxx . . $ INDI/Property#`operator INDI::PropertyView<_ILight> *`(5771a6f4cdf19338). INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<ILightcxx . . $ ILight#> *() const { return getLightcxx . . $ INDI/Property#getLight(5771a6f4cdf19338).(); } |
| 170 | operatorcxx . . $ INDI/Property#`operator INDI::PropertyView<_IBLOB> *`(44b9300d803ba00c). INDIcxx . . $ INDI/::PropertyViewcxx . . $ INDI/PropertyView#<IBLOBcxx . . $ IBLOB#> *() const { return getBLOBcxx . . $ INDI/Property#getBLOB(44b9300d803ba00c).(); } |
| 171 | bool operatorcxx . . $ INDI/Property#`operator!=`(b102b25da64d45e5). != (stdcxx . . $ std/::nullptr_tcxx . . $ std/nullptr_t#) const { return isValidcxx . . $ INDI/Property#isValid(50ce9a9e25b4a850).(); } |
| 172 | bool operatorcxx . . $ INDI/Property#`operator==`(b102b25da64d45e5). == (stdcxx . . $ std/::nullptr_tcxx . . $ std/nullptr_t#) const { return !isValidcxx . . $ INDI/Property#isValid(50ce9a9e25b4a850).(); } |
| 173 | operatorcxx . . $ INDI/Property#`operator bool`(50ce9a9e25b4a850). bool() const { return isValidcxx . . $ INDI/Property#isValid(50ce9a9e25b4a850).(); } |
| 174 | #endif |
| 175 | |
| 176 | protected: |
| 177 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<PropertyPrivatecxx . . $ INDI/PropertyPrivate#> d_ptrcxx . . $ INDI/Property#d_ptr.; |
| 178 | Propertycxx . . $ INDI/Property#Property(b979c61994ed969c).(const stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<PropertyPrivatecxx . . $ INDI/PropertyPrivate#> &dd); |
| 179 | Propertycxx . . $ INDI/Property#Property(29c6c1b33ef7e4a4).(PropertyPrivatecxx . . $ INDI/PropertyPrivate# &dd); |
| 180 | friend class PropertyNumbercxx . . $ INDI/PropertyNumber#; |
| 181 | friend class PropertyTextcxx . . $ INDI/PropertyText#; |
| 182 | friend class PropertySwitchcxx . . $ INDI/PropertySwitch#; |
| 183 | friend class PropertyLightcxx . . $ INDI/PropertyLight#; |
| 184 | friend class PropertyBlobcxx . . $ INDI/PropertyBlob#; |
| 185 | }; |
| 186 | |
| 187 | } // namespace INDI |
| 188 | |
| 189 | #ifdef QT_CORE_LIB |
| 190 | #include <QMetaType> |
| 191 | Q_DECLARE_METATYPE(INDI::Property) |
| 192 | static int indi_property_metatype_id = QMetaTypeId< INDI::Property >::qt_metatype_id(); |
| 193 | #endif |