Instrument Neutral Distributed Interface INDI  2.0.2
indiproperty_p.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Jasem Mutlaq. All rights reserved.
3  2022 Pawel Soja <kernel32.pl@gmail.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
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  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 *******************************************************************************/
19 
20 #pragma once
21 
22 #include "indimacros.h"
23 #include "indibase.h"
24 #include "indiproperty.h"
25 #include "basedevice.h"
26 #include <memory>
27 #include <functional>
28 
29 namespace INDI
30 {
31 
32 template <typename T, typename U>
33 static inline std::shared_ptr<T> property_private_cast(const std::shared_ptr<U> &r)
34 {
35  static struct Invalid : public T
36  {
37  Invalid() : T(16) { this->type = INDI_UNKNOWN; }
38  } invalid;
39  auto result = std::dynamic_pointer_cast<T>(r);
40  return result != nullptr ? result : make_shared_weak(&invalid);
41 }
42 
43 class BaseDevice;
45 {
46  public:
47  void *property = nullptr;
50  bool registered = false;
51  bool dynamic = false;
52 
53  std::function<void()> onUpdateCallback;
54 
61 
62  virtual ~PropertyPrivate();
63 
64 #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILE
65  Property self {make_shared_weak(this)};
66 #endif
67 };
68 
69 }
Class to provide basic INDI device functionality.
Definition: basedevice.h:52
PropertyPrivate(void *property, INDI_PROPERTY_TYPE type)
std::function< void()> onUpdateCallback
INDI_PROPERTY_TYPE type
Provides generic container for INDI properties.
Definition: indiproperty.h:48
INDI_PROPERTY_TYPE
Definition: indibasetypes.h:23
@ INDI_UNKNOWN
Definition: indidriver.c:62
Namespace to encapsulate INDI client, drivers, and mediator classes.
__le16 type
Definition: pwc-ioctl.h:0
Provides decorator for Low-Level IXXXVectorProperty/IXXX.