Instrument Neutral Distributed Interface INDI 2.2.5
indiproperties.h
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#pragma once
19
20#include "indiproperty.h"
21#include "indimacros.h"
22#include <vector>
23#include <deque>
24#include <algorithm>
25
26#define INDI_PROPERTIES_BACKWARD_COMPATIBILE
27namespace INDI
28{
29
30class PropertiesPrivate;
32{
33 DECLARE_PRIVATE(Properties)
34
35 public:
36 using iterator = std::deque<INDI::Property>::iterator;
37 using const_iterator = std::deque<INDI::Property>::const_iterator;
38
39 // #PS 2024: workaround; SWIG 4.2.0 - SwigSmartPointer, does not create a pointer, just an uninitialized reference.
40 // using reference = std::deque<INDI::Property>::reference;
41 // using const_reference = std::deque<INDI::Property>::const_reference;
44
45 using size_type = std::deque<INDI::Property>::size_type;
46
47 public:
48 Properties();
50
51 public:
52 void push_back(const INDI::Property &property);
53 void push_back(INDI::Property &&property);
54 void clear();
55
56 public:
57 bool empty() const;
58
59 public:
60 size_type size() const;
61
62 public:
64 const_reference at(size_type pos) const;
65
68
70 const_reference front() const;
71
73 const_reference back() const;
74
75 public:
77 iterator end();
78
79 const_iterator begin() const;
80 const_iterator end() const;
81
82 public:
85 iterator erase(iterator first, iterator last);
87
88 template<typename Predicate>
89 iterator erase_if(Predicate predicate);
90
91 public:
92#ifdef INDI_PROPERTIES_BACKWARD_COMPATIBILE
94 const INDI::Properties operator *() const;
95
97 const Properties *operator->() const;
98
99 operator std::vector<INDI::Property *> *();
100 operator const std::vector<INDI::Property *> *() const;
101
102 operator Properties *();
103 operator const Properties *() const;
104#endif
105
106 protected:
107 std::shared_ptr<PropertiesPrivate> d_ptr;
108 Properties(std::shared_ptr<PropertiesPrivate> dd);
109};
110
111template<typename Predicate>
113{
114 return erase(std::remove_if(begin(), end(), predicate), end());
115}
116
117}
Properties * operator->()
bool empty() const
INDI::Properties operator*()
iterator erase(iterator pos)
std::deque< INDI::Property >::const_iterator const_iterator
reference operator[](size_type pos)
std::deque< INDI::Property >::size_type size_type
std::shared_ptr< PropertiesPrivate > d_ptr
void push_back(const INDI::Property &property)
reference at(size_type pos)
std::deque< INDI::Property >::iterator iterator
iterator erase_if(Predicate predicate)
size_type size() const
Provides generic container for INDI properties.
Namespace to encapsulate INDI client, drivers, and mediator classes.