Instrument Neutral Distributed Interface INDI 2.2.5
indipropertyblob.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 by Pawel Soja <[email protected]>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#include "indipropertyblob.h"
20#include "indipropertyblob_p.h"
21
22namespace INDI
23{
24
28
30{
31 for (auto &it: widgets)
32 {
33 auto blob = it.getBlob();
34 if (blob != nullptr && deleter != nullptr)
35 {
36 deleter(blob);
37 }
38 }
39}
40
44
46 : PropertyBasic<IBLOB>(property_private_cast<PropertyBlobPrivate>(property.d_ptr))
47{ }
48
51
52void PropertyBlob::setBlobDeleter(const std::function<void(void *&)> &deleter)
53{
54 D_PTR(PropertyBlob);
55 d->deleter = deleter;
56}
57
59 const int sizes[], const int blobsizes[], const char * const blobs[], const char * const formats[],
60 const char * const names[], int n
61)
62{
63 D_PTR(PropertyBlob);
64 return d->typedProperty.update(sizes, blobsizes, blobs, formats, names, n) && (emitUpdate(), true);
65}
66
68 const char *device, const char *name, const char *label, const char *group,
69 IPerm permission, double timeout, IPState state
70)
71{
72 D_PTR(PropertyBlob);
73 d->typedProperty.setWidgets(d->widgets.data(), d->widgets.size());
74 d->typedProperty.fill(device, name, label, group, permission, timeout, state);
75}
76
77}
hid_device * device
std::vector< WidgetView< IBLOB > > widgets
std::function< void(void *&)> deleter
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void setBlobDeleter(const std::function< void(void *&)> &deleter)
Set the Blob Deleter function You can define a function to release the memory of the elements....
bool update(const int sizes[], const int blobsizes[], const char *const blobs[], const char *const formats[], const char *const names[], int n)
Provides generic container for INDI properties.
friend class PropertyBlob
IPerm
Permission hint, with respect to client.
Definition indiapi.h:181
IPState
Property state.
Definition indiapi.h:158
Namespace to encapsulate INDI client, drivers, and mediator classes.
One Blob (Binary Large Object) descriptor.