30 #include <type_traits>
50 #define PROPERTYVIEW_BASE_ACCESS public
95 template <
typename X,
typename Needed>
107 void setName(
const char *name);
108 void setName(
const std::string &name);
111 void setLabel(
const std::string &label);
131 bool setRule(
const std::string &rule);
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>
152 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
197 return this->timestamp;
217 return !strcmp(
getName(), otherName);
226 return !strcmp(
getLabel(), otherLabel);
236 void vapply(
const char *format, va_list args)
238 void vdefine(
const char *format, va_list args)
256 template <
typename X = T, enable_if_is_same_t<X, IText> = true>
258 const char *
device,
const char *name,
const char *label,
const char *group,
262 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
264 const char *
device,
const char *name,
const char *label,
const char *group,
268 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
270 const char *
device,
const char *name,
const char *label,
const char *group,
274 template <
typename X = T, enable_if_is_same_t<X, ILight> = true>
276 const char *
device,
const char *name,
const char *label,
const char *group,
280 template <
typename X = T, enable_if_is_same_t<X, IBLOB> = true>
282 const char *
device,
const char *name,
const char *label,
const char *group,
287 template <
typename X = T, enable_if_is_same_t<X, IText> = true>
288 bool update(
const char *
const texts[],
const char *
const names[],
int n);
291 template <
typename X = T, enable_if_is_same_t<X, INumber> = true>
292 bool update(
const double values[],
const char *
const names[],
int n);
295 template <
typename X = T, enable_if_is_same_t<X, ISwitch> = true>
304 template <
typename X = T, enable_if_is_same_t<X, IBLOB> = true>
306 const int sizes[],
const int blobsizes[],
const char *
const blobs[],
const char *
const formats[],
307 const char *
const names[],
int n
333 memset(
this, 0,
sizeof(*
this));
358 memset(
this, 0,
sizeof(*
this));
362 this->text =
nullptr;
367 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
385 memset(
this, 0,
sizeof(*
this));
401 INDI::strlcpy(this->name, name);
405 setName(name.data());
410 INDI::strlcpy(this->label, label);
414 setLabel(label.data());
420 INDI::strlcpy(this->text =
static_cast<char*
>(realloc(this->text, size + 1)), text, size + 1);
424 setText(text, strlen(text));
428 setText(text.data(), text.size());
448 return this->text ? this->text :
"";
459 return !strcmp(getName(), otherName);
463 return getName() == otherName;
468 return !strcmp(getLabel(), otherLabel);
472 return getLabel() == otherLabel;
476 void fill(
const char *name,
const char *label,
const char *initialText)
479 void fill(
const std::string &name,
const std::string &label,
const std::string &initialText)
481 fill(name.c_str(), label.c_str(), initialText.c_str());
494 memset(
this, 0,
sizeof(*
this));
499 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
513 memset(
this, 0,
sizeof(*
this));
529 INDI::strlcpy(this->name, name);
533 setName(name.data());
538 INDI::strlcpy(this->label, label);
542 setLabel(label.data());
547 INDI::strlcpy(this->format, format);
551 setLabel(format.data());
621 return !strcmp(getName(), otherName);
625 return getName() == otherName;
630 return !strcmp(getLabel(), otherLabel);
634 return getLabel() == otherLabel;
638 void fill(
const char *name,
const char *label,
const char *format,
639 double min,
double max,
double step,
double value)
642 void fill(
const std::string &name,
const std::string &label,
const std::string &format,
643 double min,
double max,
double step,
double value)
645 fill(name.c_str(), label.c_str(), format.c_str(),
min,
max, step, value);
658 memset(
this, 0,
sizeof(*
this));
663 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
677 memset(
this, 0,
sizeof(*
this));
693 INDI::strlcpy(this->name, name);
697 setName(name.data());
702 INDI::strlcpy(this->label, label);
706 setLabel(label.data());
752 return !strcmp(getName(), otherName);
756 return getName() == otherName;
761 return !strcmp(getLabel(), otherLabel);
765 return getLabel() == otherLabel;
769 void fill(
const char *name,
const char *label,
ISState state =
ISS_OFF)
774 fill(name.c_str(), label.c_str(), state);
787 memset(
this, 0,
sizeof(*
this));
792 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
806 memset(
this, 0,
sizeof(*
this));
822 INDI::strlcpy(this->name, name);
826 setName(name.data());
831 INDI::strlcpy(this->label, label);
835 setLabel(label.data());
881 return !strcmp(getName(), otherName);
885 return getName() == otherName;
890 return !strcmp(getLabel(), otherLabel);
894 return getLabel() == otherLabel;
898 void fill(
const char *name,
const char *label,
IPState state =
IPS_OK)
903 fill(name.c_str(), label.c_str(), state);
916 memset(
this, 0,
sizeof(*
this));
921 memset(
static_cast<Type*
>(&other), 0,
sizeof(other));
935 memset(
this, 0,
sizeof(*
this));
951 INDI::strlcpy(this->name, name);
955 setName(name.data());
960 INDI::strlcpy(this->label, label);
964 setLabel(label.data());
969 INDI::strlcpy(this->format, format);
973 setLabel(format.data());
982 this->bloblen = size;
1006 return this->format;
1018 return std::string(
static_cast<const char*
>(this->blob), this->bloblen);
1022 return this->bloblen;
1037 return !strcmp(getName(), otherName);
1041 return getName() == otherName;
1046 return !strcmp(getLabel(), otherLabel);
1050 return getLabel() == otherLabel;
1054 void fill(
const char *name,
const char *label,
const char *format)
1057 void fill(
const std::string &name,
const std::string &label,
const std::string &format)
1059 fill(name.c_str(), label.c_str(), format.c_str());
1077 template <
typename T>
1080 memset(
this, 0,
sizeof(*
this));
1083 template <
typename T>
1086 INDI::strlcpy(this->
device, name);
1089 template <
typename T>
1092 setDeviceName(name.data());
1095 template <
typename T>
1098 INDI::strlcpy(this->name, name);
1101 template <
typename T>
1104 setName(name.data());
1107 template <
typename T>
1110 INDI::strlcpy(this->label, label);
1113 template <
typename T>
1116 setLabel(label.data());
1119 template <
typename T>
1122 INDI::strlcpy(this->group, name);
1125 template <
typename T>
1128 setGroupName(name.data());
1131 template <
typename T>
1137 template <
typename T>
1140 INDI::strlcpy(this->timestamp, timestamp);
1143 template <
typename T>
1146 setTimestamp(timestamp.data());
1149 template <
typename T>
1156 template <
typename T>
1192 template <
typename T>
1195 this->timeout = timeout;
1202 template <
typename T>
1205 this->p = permission;
1212 template <
typename T>
1222 template <
typename T>
1234 template <
typename T>
1270 template <
typename T>
1282 template <
typename T>
1294 template <
typename T>
1297 return this->timeout;
1310 this->ntp = int(size);
1317 this->nnp = int(size);
1324 this->nsp = int(size);
1331 this->nlp = int(size);
1338 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.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
const char * ruleStr(ISRule r)
INumber * IUFindNumber(const INumberVectorProperty *nvp, const char *name)
Find an INumber member in a number text property.
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.
ISwitch * IUFindOnSwitch(const ISwitchVectorProperty *svp)
Returns the first ON switch it finds in the vector switch property.
void IUSaveConfigBLOB(FILE *fp, const IBLOBVectorProperty *bvp)
Add a BLOB vector property value to the configuration file.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
const char * pstateStr(IPState s)
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.
IBLOB * IUFindBLOB(const IBLOBVectorProperty *bvp, const char *name)
Find an IBLOB member in a vector BLOB property.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
ILight * IUFindLight(const ILightVectorProperty *lvp, const char *name)
Find an ILight member in a vector Light property.
int crackISRule(const char *str, ISRule *ip)
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
const char * sstateStr(ISState s)
const char * permStr(IPerm p)
int crackISState(const char *str, ISState *ip)
Extract switch state (On or Off) from the supplied string.
ISwitch * IUFindSwitch(const ISwitchVectorProperty *svp, const char *name)
Find an ISwitch member in a vector switch property.
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
WidgetType * findOnSwitch() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
WidgetType * begin() const
void fill(const char *device, const char *name, const char *label, const char *group, IPState state)
const char * getName() const
const char * getPermissionAsString() const
const char * getGroupName() const
void void void apply() const
const char * getStateAsString() const
bool isLabelMatch(const std::string &otherLabel) const
void setTimestamp(const char *timestamp)
void setDeviceName(const char *name)
void setName(const char *name)
double getTimeout() const
const char * getTimestamp() const
const char * getDeviceName() const
bool update(const char *const texts[], const char *const names[], int n)
const char * getRuleAsString() const
bool isNameMatch(const char *otherName) const
int findOnSwitchIndex() 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)
IPerm getPermission() const
WidgetType * at(size_t index) const
void vdefine(const char *format, va_list args) const
void setPermission(IPerm permission)
WidgetType * widget() const
static PropertyView< T > * cast(PropertyType *raw)
bool update(const double values[], const char *const names[], int n)
bool update(const ISState states[], const char *const names[], int n)
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)
void setLabel(const char *label)
const char * getLabel() const
typename WidgetTraits< T >::PropertyType PropertyType
WidgetType * findWidgetByName(const char *name) const
typename std::enable_if< std::is_same< X, Needed >::value, bool >::type enable_if_is_same_t
void setWidgets(WidgetType *w, size_t count)
void vapply(const char *format, va_list args) const
bool isLabelMatch(const char *otherLabel) const
void fill(const std::string &name, const std::string &label, const std::string &initialText)
WidgetView(const WidgetView &other)
bool isLabelMatch(const std::string &otherLabel) const
bool isNameMatch(const std::string &otherName) const
WidgetView & operator=(const WidgetView &other)
const char * getName() const
void setText(const char *text)
WidgetView(WidgetView &&other)
void setLabel(const std::string &label)
const char * getLabel() 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)
void setName(const std::string &name)
bool isLabelMatch(const char *otherLabel) const
WidgetView & operator=(WidgetView &&other)
void setParent(PropertyView< Type > *parent)
bool isNameMatch(const char *otherName) const
const char * getText() const
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.