50#define PROPERTYVIEW_BASE_ACCESS public
95 template <
typename X,
typename Needed>
133 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
139 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
145 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
149 return (onSwitch && onSwitch->isNameMatch(name));
152 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
158 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
163 return onSwitch->getName();
165 return std::string();
169 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
214 return this->timestamp;
234 return !strcmp(
getName(), otherName);
243 return !strcmp(
getLabel(), otherLabel);
255 void vapply(
const char *format, va_list args)
257 void vdefine(
const char *format, va_list args)
275 template <
typename X = T, enable_if_is_same_t<X, IText> = true>
277 const char *
device,
const char *name,
const char *label,
const char *group,
281 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
283 const char *
device,
const char *name,
const char *label,
const char *group,
287 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
289 const char *
device,
const char *name,
const char *label,
const char *group,
293 template <
typename X = T, enable_if_is_same_t<X, ILight> = true>
295 const char *
device,
const char *name,
const char *label,
const char *group,
299 template <
typename X = T, enable_if_is_same_t<X, IBLOB> = true>
301 const char *
device,
const char *name,
const char *label,
const char *group,
306 template <
typename X = T, enable_if_is_same_t<X, IText> = true>
307 bool update(
const char *
const texts[],
const char *
const names[],
int n);
310 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
311 bool update(
const double values[],
const char *
const names[],
int n);
314 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
323 template <
typename X = T, enable_if_is_same_t<X, IBLOB> = true>
325 const int sizes[],
const int blobsizes[],
const char *
const blobs[],
const char *
const formats[],
326 const char *
const names[],
int n
329 template <
typename X = T, enable_if_is_same_t<X, IText> = true>
330 bool isUpdated(
const char *
const texts[],
const char *
const names[],
int n)
const;
332 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
333 bool isUpdated(
const double values[],
const char *
const names[],
int n)
const;
335 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
361 memset((
void*)
this, 0,
sizeof(*
this));
386 memset((
void*)
this, 0,
sizeof(*
this));
390 this->text =
nullptr;
391 if (other.text !=
nullptr)
398 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
406 std::swap(
static_cast<Type &
>(other),
static_cast<Type &
>(*
this));
416 memset((
void*)
this, 0,
sizeof(*
this));
432 INDI::strlcpy(this->name, name);
441 INDI::strlcpy(this->label, label);
451 INDI::strlcpy(this->text =
static_cast<char*
>(realloc(this->text, size + 1)), text, size + 1);
459 setText(text.data(), text.size());
479 return this->text ? this->text :
"";
490 return !strcmp(
getName(), otherName);
499 return !strcmp(
getLabel(), otherLabel);
512 void fill(
const char *name,
const char *label,
const char *initialText)
515 void fill(
const std::string &name,
const std::string &label,
const std::string &initialText)
517 fill(name.c_str(), label.c_str(), initialText.c_str());
530 memset((
void*)
this, 0,
sizeof(*
this));
535 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
543 std::swap(
static_cast<Type &
>(other),
static_cast<Type &
>(*
this));
549 memset((
void*)
this, 0,
sizeof(*
this));
565 INDI::strlcpy(this->name, name);
574 INDI::strlcpy(this->label, label);
583 INDI::strlcpy(this->format, format);
657 return !strcmp(
getName(), otherName);
666 return !strcmp(
getLabel(), otherLabel);
674 void fill(
const char *name,
const char *label,
const char *format,
675 double min,
double max,
double step,
double value)
678 void fill(
const std::string &name,
const std::string &label,
const std::string &format,
679 double min,
double max,
double step,
double value)
681 fill(name.c_str(), label.c_str(), format.c_str(),
min,
max, step, value);
694 memset((
void*)
this, 0,
sizeof(*
this));
699 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
707 std::swap(
static_cast<Type &
>(other),
static_cast<Type &
>(*
this));
713 memset((
void*)
this, 0,
sizeof(*
this));
729 INDI::strlcpy(this->name, name);
738 INDI::strlcpy(this->label, label);
788 return !strcmp(
getName(), otherName);
797 return !strcmp(
getLabel(), otherLabel);
805 void fill(
const char *name,
const char *label,
ISState state =
ISS_OFF)
810 fill(name.c_str(), label.c_str(), state);
823 memset((
void*)
this, 0,
sizeof(*
this));
828 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
836 std::swap(
static_cast<Type &
>(other),
static_cast<Type &
>(*
this));
842 memset((
void*)
this, 0,
sizeof(*
this));
858 INDI::strlcpy(this->name, name);
867 INDI::strlcpy(this->label, label);
917 return !strcmp(
getName(), otherName);
926 return !strcmp(
getLabel(), otherLabel);
934 void fill(
const char *name,
const char *label,
IPState state =
IPS_OK)
939 fill(name.c_str(), label.c_str(), state);
952 memset((
void*)
this, 0,
sizeof(*
this));
957 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
965 std::swap(
static_cast<Type &
>(other),
static_cast<Type &
>(*
this));
971 memset((
void*)
this, 0,
sizeof(*
this));
987 INDI::strlcpy(this->name, name);
996 INDI::strlcpy(this->label, label);
1005 INDI::strlcpy(this->format, format);
1018 this->bloblen = size;
1042 return this->format;
1054 return std::string(
static_cast<const char*
>(this->blob), this->bloblen);
1058 return this->bloblen;
1073 return !strcmp(
getName(), otherName);
1077 return getName() == otherName;
1082 return !strcmp(
getLabel(), otherLabel);
1090 void fill(
const char *name,
const char *label,
const char *format)
1093 void fill(
const std::string &name,
const std::string &label,
const std::string &format)
1095 fill(name.c_str(), label.c_str(), format.c_str());
1113template <
typename T>
1116 memset((
void*)
this, 0,
sizeof(*
this));
1119template <
typename T>
1122 INDI::strlcpy(this->
device, name);
1125template <
typename T>
1131template <
typename T>
1134 INDI::strlcpy(this->name, name);
1137template <
typename T>
1143template <
typename T>
1146 INDI::strlcpy(this->label, label);
1149template <
typename T>
1155template <
typename T>
1158 INDI::strlcpy(this->group, name);
1161template <
typename T>
1167template <
typename T>
1173template <
typename T>
1176 INDI::strlcpy(this->timestamp, timestamp);
1179template <
typename T>
1185template <
typename T>
1192template <
typename T>
1288template <
typename T>
1291 this->timeout = timeout;
1298template <
typename T>
1301 this->p = permission;
1308template <
typename T>
1318template <
typename T>
1330template <
typename T>
1366template <
typename T>
1378template <
typename T>
1390template <
typename T>
1393 return this->timeout;
1406 this->ntp = int(size);
1413 this->nnp = int(size);
1420 this->nsp = int(size);
1427 this->nlp = int(size);
1434 this->nbp = int(size);
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
struct _IBLOBVectorProperty IBLOBVectorProperty
IPerm
Permission hint, with respect to client.
struct _ISwitchVectorProperty ISwitchVectorProperty
ISRule
Switch vector rule hint.
struct _ITextVectorProperty ITextVectorProperty
struct _ILightVectorProperty ILightVectorProperty
struct _INumberVectorProperty INumberVectorProperty
int IUSnoopSwitch(XMLEle *root, ISwitchVectorProperty *svp)
Update a snooped switch vector property from the given XML root element.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
int IULoadConfigSwitch(const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
const char * ruleStr(ISRule r)
ILight * IUFindLight(const ILightVectorProperty *lvp, const char *name)
Find an ILight member in a vector Light property.
int IULoadConfigNumber(const INumberVectorProperty *nvp)
Load a number vector property value from the configuration file.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
INumber * IUFindNumber(const INumberVectorProperty *nvp, const char *name)
Find an INumber member in a number text property.
int IUSnoopBLOB(XMLEle *root, IBLOBVectorProperty *bvp)
Update a snooped BLOB vector property from the given XML root element.
int IUSnoopLight(XMLEle *root, ILightVectorProperty *lvp)
Update a snooped light vector property from the given XML root element.
ISwitch * IUFindSwitch(const ISwitchVectorProperty *svp, const char *name)
Find an ISwitch member in a vector switch property.
void IUSaveConfigBLOB(FILE *fp, const IBLOBVectorProperty *bvp)
Add a BLOB vector property value to the configuration file.
int IUSnoopText(XMLEle *root, ITextVectorProperty *tvp)
Update a snooped text vector property from the given XML root element.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
int IUSnoopNumber(XMLEle *root, INumberVectorProperty *nvp)
Update a snooped number vector property from the given XML root element.
const char * sstateStr(ISState s)
const char * permStr(IPerm p)
IBLOB * IUFindBLOB(const IBLOBVectorProperty *bvp, const char *name)
Find an IBLOB member in a vector BLOB property.
ISwitch * IUFindOnSwitch(const ISwitchVectorProperty *svp)
Returns the first ON switch it finds in the vector switch property.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
const char * pstateStr(IPState s)
int IULoadConfigText(const ITextVectorProperty *tvp)
Load a text vector property value from the configuration file.
int crackISRule(const char *str, ISRule *ip)
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
int crackISState(const char *str, ISState *ip)
Extract switch state (On or Off) from the supplied string.
Interface to the reference INDI C API device implementation on the Device Driver side.
#define ATTRIBUTE_FORMAT_PRINTF(A, B)
*brief user defined string literal for JSON values *sa std::size_t n
#define PROPERTYVIEW_BASE_ACCESS
Namespace to encapsulate INDI client, drivers, and mediator classes.
WidgetView< ISwitch > WidgetViewSwitch
PropertyView< IBLOB > PropertyViewBlob
WidgetView< ILight > WidgetViewLight
WidgetView< IText > WidgetViewText
PropertyView< ISwitch > PropertyViewSwitch
PropertyView< ILight > PropertyViewLight
WidgetView< IBLOB > WidgetViewBlob
PropertyView< INumber > PropertyViewNumber
PropertyView< IText > PropertyViewText
WidgetView< INumber > WidgetViewNumber
One Blob (Binary Large Object) descriptor.
Provides decorator for Low-Level IXXXVectorProperty/IXXX.
bool isNameMatch(const std::string &otherName) const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPState state)
std::string findOnSwitchName() const
void setGroupName(const std::string &name)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
const char * getRuleAsString() const
const char * getLabel() const
void void void apply() const
WidgetType * widget() const
friend class DefaultDevice
bool isSwitchOn(const std::string &name) const
void setTimestamp(const std::string ×tamp)
const char * getName() const
bool isLabelMatch(const std::string &otherLabel) const
void setTimestamp(const char *timestamp)
void setDeviceName(const char *name)
void setName(const char *name)
WidgetType * at(size_t index) const
double getTimeout() const
bool isUpdated(const ISState states[], const char *const names[], int n) const
bool update(const char *const texts[], const char *const names[], int n)
bool isNameMatch(const char *otherName) const
WidgetType * findOnSwitch() const
int findOnSwitchIndex() const
void void define(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isUpdated(const double values[], const char *const names[], int n) const
void setTimeout(double timeout)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
bool setRule(const std::string &rule)
void setLabel(const std::string &label)
IPerm getPermission() const
void vdefine(const char *format, va_list args) const
const char * getTimestamp() const
void setPermission(IPerm permission)
friend class PropertyPrivate
bool isUpdated(const char *const texts[], const char *const names[], int n) const
void setDeviceName(const std::string &name)
bool update(const double values[], const char *const names[], int n)
bool update(const ISState states[], const char *const names[], int n)
const char * getStateAsString() const
void setState(IPState state)
void setRule(ISRule rule)
bool update(const int sizes[], const int blobsizes[], const char *const blobs[], const char *const formats[], const char *const names[], int n)
WidgetView< IText > WidgetType
void setGroupName(const char *name)
WidgetType * begin() const
void setWidgets(WidgetType(&w)[N])
void setLabel(const char *label)
const char * getDeviceName() const
typename WidgetTraits< T >::PropertyType PropertyType
WidgetType * findWidgetByName(const char *name) const
void setName(const std::string &name)
static PropertyView< T > * cast(PropertyType *raw)
typename std::enable_if< std::is_same< X, Needed >::value, bool >::type enable_if_is_same_t
const char * getPermissionAsString() const
void setWidgets(WidgetType *w, size_t count)
void vapply(const char *format, va_list args) const
const char * getGroupName() const
bool isLabelMatch(const char *otherLabel) const
void fill(const std::string &name, const std::string &label, const std::string &initialText)
WidgetView(const WidgetView< Type > &other)
bool isLabelMatch(const std::string &otherLabel) const
bool isNameMatch(const std::string &otherName) const
void setText(const char *text)
WidgetView< Type > & operator=(const WidgetView< Type > &other)
void setLabel(const std::string &label)
const char * getLabel() const
void fill(const char *name, const char *label, const char *initialText)
const char * getText() const
void setName(const char *name)
void setText(const std::string &text)
void setText(const char *text, size_t size)
void setParent(ITextVectorProperty *parent)
void setLabel(const char *label)
const char * getName() const
void setName(const std::string &name)
bool isLabelMatch(const char *otherLabel) const
WidgetView< Type > & operator=(WidgetView< Type > &&other)
void setParent(PropertyView< Type > *parent)
bool isNameMatch(const char *otherName) const
friend struct PropertyView
WidgetView(WidgetView< Type > &&other)