1 /*
2     Copyright (C) 2021 by Pawel Soja <kernel32.pl@gmail.com>
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 #pragma once
19 
20 #include "indiproperties.h"
21 
22 namespace INDI
23 {
24 
25 #ifdef INDI_PROPERTY_BACKWARD_COMPATIBILE
26 template <typename T>
make_shared_weak(T * object)27 static inline std::shared_ptr<T> make_shared_weak(T *object)
28 {
29     return std::shared_ptr<T>(object, [](T*){});
30 }
31 #endif
32 
33 class PropertiesPrivate
34 {
35 public:
36     PropertiesPrivate();
37     virtual ~PropertiesPrivate();
38 
39 public:
40     std::deque<INDI::Property> properties;
41 #ifdef INDI_PROPERTIES_BACKWARD_COMPATIBILE
42     mutable std::vector<INDI::Property *> propertiesBC;
43     Properties self {make_shared_weak(this)};
44 #endif
45 };
46 
47 }
48