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));
416 memset((
void*)
this, 0,
sizeof(*
this));
432 INDI::strlcpy(this->name, name);
436 setName(name.data());
441 INDI::strlcpy(this->label, label);
445 setLabel(label.data());
451 INDI::strlcpy(this->text =
static_cast<char*
>(realloc(this->text, size + 1)), text, size + 1);
455 setText(text, strlen(text));
459 setText(text.data(), text.size());
479 return this->text ? this->text :
"";
490 return !strcmp(getName(), otherName);
494 return getName() == otherName;
499 return !strcmp(getLabel(), otherLabel);
503 return getLabel() == otherLabel;
508 return getText()[0] ==
'\0';
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));
549 memset((
void*)
this, 0,
sizeof(*
this));
565 INDI::strlcpy(this->name, name);
569 setName(name.data());
574 INDI::strlcpy(this->label, label);
578 setLabel(label.data());
583 INDI::strlcpy(this->format, format);
587 setLabel(format.data());
657 return !strcmp(getName(), otherName);
661 return getName() == otherName;
666 return !strcmp(getLabel(), otherLabel);
670 return 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));
713 memset((
void*)
this, 0,
sizeof(*
this));
729 INDI::strlcpy(this->name, name);
733 setName(name.data());
738 INDI::strlcpy(this->label, label);
742 setLabel(label.data());
788 return !strcmp(getName(), otherName);
792 return getName() == otherName;
797 return !strcmp(getLabel(), otherLabel);
801 return 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));
842 memset((
void*)
this, 0,
sizeof(*
this));
858 INDI::strlcpy(this->name, name);
862 setName(name.data());
867 INDI::strlcpy(this->label, label);
871 setLabel(label.data());
917 return !strcmp(getName(), otherName);
921 return getName() == otherName;
926 return !strcmp(getLabel(), otherLabel);
930 return 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));
971 memset((
void*)
this, 0,
sizeof(*
this));
987 INDI::strlcpy(this->name, name);
991 setName(name.data());
996 INDI::strlcpy(this->label, label);
1000 setLabel(label.data());
1005 INDI::strlcpy(this->format, format);
1009 setFormat(format.data());
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);
1086 return 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>
1128 setDeviceName(name.data());
1131template <
typename T>
1134 INDI::strlcpy(this->name, name);
1137template <
typename T>
1140 setName(name.data());
1143template <
typename T>
1146 INDI::strlcpy(this->label, label);
1149template <
typename T>
1152 setLabel(label.data());
1155template <
typename T>
1158 INDI::strlcpy(this->group, name);
1161template <
typename T>
1164 setGroupName(name.data());
1167template <
typename T>
1173template <
typename T>
1176 INDI::strlcpy(this->timestamp, timestamp);
1179template <
typename T>
1182 setTimestamp(timestamp.data());
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);
Class to provide basic INDI device functionality.
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides generic container for INDI properties.
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
IPerm
Permission hint, with respect to client.
ISRule
Switch vector rule hint.
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)
#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
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
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)
const char * getRuleAsString() const
const char * getLabel() const
void void void apply() const
WidgetType * widget() const
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
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)
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)
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
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
WidgetView(WidgetView< Type > &&other)
Holds the connection type.
BLOB (Binary Large Object) vector property descriptor.
Light vector property descriptor.
Number vector property descriptor.
Switch vector property descriptor.
Text vector property descriptor.