Instrument Neutral Distributed Interface INDI  1.9.2
indiproperty.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "indibase.h"
22 #include "indiutility.h"
23 
24 #include "indipropertyview.h"
25 
26 #include "indidriver.h"
27 
28 #include <memory>
29 #include <cstdarg>
30 
31 #define INDI_PROPERTY_BACKWARD_COMPATIBILE
32 namespace INDI
33 {
34 class BaseDevice;
35 
42 class PropertyPrivate;
43 class Property
44 {
45  DECLARE_PRIVATE(Property)
46 public:
47  Property();
48  Property(void *property, INDI_PROPERTY_TYPE type);
50  Property(ITextVectorProperty *property);
52  Property(ILightVectorProperty *property);
53  Property(IBLOBVectorProperty *property);
54 
55  ~Property();
56 
57 public:
58  void setProperty(void *);
60  void setRegistered(bool r);
61  void setDynamic(bool d);
62  void setBaseDevice(BaseDevice *idp);
63 
64 public:
65  void *getProperty() const;
67  const char *getTypeAsString() const;
68  bool getRegistered() const;
69  bool isDynamic() const;
70  BaseDevice *getBaseDevice() const;
71 
72 public: // Convenience Functions
73  void setName(const char *name);
74  void setLabel(const char *label);
75  void setGroupName(const char *groupName);
76  void setDeviceName(const char *deviceName);
77  void setTimestamp(const char *timestamp);
78  void setState(IPState state);
79  void setPermission(IPerm permission);
80  void setTimeout(double timeout);
81 
82 public: // Convenience Functions
83  const char *getName() const;
84  const char *getLabel() const;
85  const char *getGroupName() const;
86  const char *getDeviceName() const;
87  const char *getTimestamp() const;
88  IPState getState() const;
89  const char *getStateAsString() const;
90  IPerm getPermission() const;
91 
92 public:
93  bool isEmpty() const;
94  bool isValid() const;
95 
96  bool isNameMatch(const char *otherName) const;
97  bool isNameMatch(const std::string &otherName) const;
98 
99  bool isLabelMatch(const char *otherLabel) const;
100  bool isLabelMatch(const std::string &otherLabel) const;
101 
102 public:
103  void save(FILE *fp) const;
104 
105 public:
106  void apply(const char *format, ...) const ATTRIBUTE_FORMAT_PRINTF(2, 3);
107  void define(const char *format, ...) const ATTRIBUTE_FORMAT_PRINTF(2, 3);
108 
109  void apply() const { apply(nullptr); }
110  void define() const { define(nullptr); }
111 
112 public:
118 
119 public:
120 #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILE
122  const INDI::Property* operator->() const;
123 
124  operator INDI::Property *();
125  operator const INDI::Property *() const;
126 #endif
127 
128 protected:
129  std::shared_ptr<PropertyPrivate> d_ptr;
130  Property(std::shared_ptr<PropertyPrivate> dd);
132 };
133 
134 } // namespace INDI
135 
136 #ifdef QT_CORE_LIB
137 #include <QMetaType>
138 Q_DECLARE_METATYPE(INDI::Property)
139 static int indi_property_metatype_id = QMetaTypeId< INDI::Property >::qt_metatype_id();
140 #endif
INDI::Property::operator->
INDI::Property * operator->()
Definition: indiproperty.cpp:81
INDI::Property::setProperty
void setProperty(void *)
Definition: indiproperty.cpp:165
indiutility.h
indibase.h
INDI::Property::getRegistered
bool getRegistered() const
Definition: indiproperty.cpp:223
IPState
IPState
Property state.
Definition: indiapi.h:158
INDI::Property::getName
const char * getName() const
Definition: indiproperty.cpp:289
_ILightVectorProperty
Light vector property descriptor.
Definition: indiapi.h:415
INDI::Property::getState
IPState getState() const
Definition: indiproperty.cpp:324
INDI::Property::setGroupName
void setGroupName(const char *groupName)
Definition: indiproperty.cpp:253
INDI::Property::getDeviceName
const char * getDeviceName() const
Definition: indiproperty.cpp:310
indidriver.h
INDI::Property::getProperty
void * getProperty() const
Definition: indiproperty.cpp:197
INDI::Property::getTypeAsString
const char * getTypeAsString() const
Definition: indiproperty.cpp:209
_IBLOBVectorProperty
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:469
INDI::Property::setTimestamp
void setTimestamp(const char *timestamp)
Definition: indiproperty.cpp:265
timestamp
const char * timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
Definition: indicom.c:334
INDI::Property::isLabelMatch
bool isLabelMatch(const char *otherLabel) const
Definition: indiproperty.cpp:370
INDI::Property::getNumber
INDI::PropertyView< INumber > * getNumber() const
Definition: indiproperty.cpp:384
INDI_PROPERTY_TYPE
INDI_PROPERTY_TYPE
Definition: indibasetypes.h:22
INDI::Property::getTimestamp
const char * getTimestamp() const
Definition: indiproperty.cpp:317
INDI::Property::setBaseDevice
void setBaseDevice(BaseDevice *idp)
Definition: indiproperty.cpp:191
INDI::Property::setType
void setType(INDI_PROPERTY_TYPE t)
Definition: indiproperty.cpp:173
INDI::Property::~Property
~Property()
Definition: indiproperty.cpp:154
INDI::Property::getPermission
IPerm getPermission() const
Definition: indiproperty.cpp:336
INDI::Property::apply
void void void apply() const
Definition: indiproperty.h:109
INDI::Property::isValid
bool isValid() const
Definition: indiproperty.cpp:350
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
INDI::Property::setLabel
void setLabel(const char *label)
Definition: indiproperty.cpp:247
INDI::Property::getBaseDevice
BaseDevice * getBaseDevice() const
Definition: indiproperty.cpp:235
type
__le16 type
Definition: pwc-ioctl.h:2
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::Property::getBLOB
INDI::PropertyView< IBLOB > * getBLOB() const
Definition: indiproperty.cpp:420
INDI::Property::setState
void setState(IPState state)
Definition: indiproperty.cpp:271
INDI::Property::d_ptr
std::shared_ptr< PropertyPrivate > d_ptr
Definition: indiproperty.h:129
INDI::Property::setDynamic
void setDynamic(bool d)
Definition: indiproperty.cpp:185
INDI::Property::getStateAsString
const char * getStateAsString() const
Definition: indiproperty.cpp:331
INDI::Property::getText
INDI::PropertyView< IText > * getText() const
Definition: indiproperty.cpp:393
INDI::Property::setDeviceName
void setDeviceName(const char *deviceName)
Definition: indiproperty.cpp:259
INDI::Property::getLabel
const char * getLabel() const
Definition: indiproperty.cpp:296
INDI::PropertyPrivate
Definition: indiproperty_p.h:52
IPerm
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:181
INDI::PropertyView< INumber >
INDI::Property::getLight
INDI::PropertyView< ILight > * getLight() const
Definition: indiproperty.cpp:402
INDI::Property::isNameMatch
bool isNameMatch(const char *otherName) const
Definition: indiproperty.cpp:356
INDI::Property::setTimeout
void setTimeout(double timeout)
Definition: indiproperty.cpp:283
INDI::Property::isDynamic
bool isDynamic() const
Definition: indiproperty.cpp:229
INDI::Property::getType
INDI_PROPERTY_TYPE getType() const
Definition: indiproperty.cpp:203
INDI::Property::getGroupName
const char * getGroupName() const
Definition: indiproperty.cpp:303
INDI::Property::Property
Property()
Definition: indiproperty.cpp:126
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Property::setRegistered
void setRegistered(bool r)
Definition: indiproperty.cpp:179
ATTRIBUTE_FORMAT_PRINTF
#define ATTRIBUTE_FORMAT_PRINTF(A, B)
Definition: indidevapi.h:140
INDI::Property::save
void save(FILE *fp) const
Definition: indiproperty.cpp:429
indipropertyview.h
INDI::Property::isEmpty
bool isEmpty() const
Definition: indiproperty.cpp:343
INDI::Property::setPermission
void setPermission(IPerm permission)
Definition: indiproperty.cpp:277
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45
INDI::Property::getSwitch
INDI::PropertyView< ISwitch > * getSwitch() const
Definition: indiproperty.cpp:411
INDI::Property::define
void define() const
Definition: indiproperty.h:110
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
INDI::Property::setName
void setName(const char *name)
Definition: indiproperty.cpp:241