Instrument Neutral Distributed Interface INDI  1.9.5
indiproperties.h
Go to the documentation of this file.
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 "indiproperty.h"
21 #include "indimacros.h"
22 #include <vector>
23 #include <deque>
24 #include <algorithm>
25 
26 #define INDI_PROPERTIES_BACKWARD_COMPATIBILE
27 namespace INDI
28 {
29 
30 class 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  using reference = std::deque<INDI::Property>::reference;
39  using const_reference = std::deque<INDI::Property>::const_reference;
40  using size_type = std::deque<INDI::Property>::size_type;
41 
42 public:
43  Properties();
44  ~Properties();
45 
46 public:
47  void push_back(const INDI::Property &property);
48  void push_back(INDI::Property &&property);
49  void clear();
50 
51 public:
52  bool empty() const;
53 
54 public:
55  size_type size() const;
56 
57 public:
58  reference at(size_type pos);
59  const_reference at(size_type pos) const;
60 
63 
64  reference front();
65  const_reference front() const;
66 
67  reference back();
68  const_reference back() const;
69 
70 public:
71  iterator begin();
72  iterator end();
73 
74  const_iterator begin() const;
75  const_iterator end() const;
76 
77 public:
78  iterator erase(iterator pos);
80  iterator erase(iterator first, iterator last);
82 
83  template<typename Predicate>
84  iterator erase_if(Predicate predicate);
85 
86 public:
87 #ifdef INDI_PROPERTIES_BACKWARD_COMPATIBILE
89  const INDI::Properties operator *() const;
90 
92  const Properties *operator->() const;
93 
94  operator std::vector<INDI::Property *> *();
95  operator const std::vector<INDI::Property *> *() const;
96 
97  operator Properties *();
98  operator const Properties *() const;
99 #endif
100 
101 protected:
102  std::shared_ptr<PropertiesPrivate> d_ptr;
103  Properties(std::shared_ptr<PropertiesPrivate> dd);
104 };
105 
106 template<typename Predicate>
107 inline Properties::iterator Properties::erase_if(Predicate predicate)
108 {
109  return erase(std::remove_if(begin(), end(), predicate), end());
110 }
111 
112 }
INDI::Properties::iterator
std::deque< INDI::Property >::iterator iterator
Definition: indiproperties.h:36
INDI::Properties::empty
bool empty() const
INDI::Properties::const_iterator
std::deque< INDI::Property >::const_iterator const_iterator
Definition: indiproperties.h:37
indimacros.h
INDI::Properties::back
reference back()
Definition: indiproperties.cpp:101
INDI::Properties::Properties
Properties()
Definition: indiproperties.cpp:30
INDI::Properties::~Properties
~Properties()
Definition: indiproperties.cpp:34
INDI::Properties
Definition: indiproperties.h:31
INDI::Properties::front
reference front()
Definition: indiproperties.cpp:89
INDI::Properties::operator->
Properties * operator->()
Definition: indiproperties.cpp:172
INDI::Properties::reference
std::deque< INDI::Property >::reference reference
Definition: indiproperties.h:38
INDI::Properties::d_ptr
std::shared_ptr< PropertiesPrivate > d_ptr
Definition: indiproperties.h:102
INDI::Properties::erase
iterator erase(iterator pos)
Definition: indiproperties.cpp:137
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
INDI::Properties::size_type
std::deque< INDI::Property >::size_type size_type
Definition: indiproperties.h:40
INDI::Properties::erase_if
iterator erase_if(Predicate predicate)
Definition: indiproperties.h:107
INDI::Properties::at
reference at(size_type pos)
Definition: indiproperties.cpp:65
INDI::Properties::end
iterator end()
Definition: indiproperties.cpp:119
INDI::Properties::operator[]
reference operator[](size_type pos)
Definition: indiproperties.cpp:77
indiproperty.h
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Properties::push_back
void push_back(const INDI::Property &property)
Definition: indiproperties.cpp:41
INDI::Properties::begin
iterator begin()
Definition: indiproperties.cpp:113
INDI::Properties::operator*
INDI::Properties operator*()
Definition: indiproperties.cpp:162
INDI::Properties::size
size_type size() const
Definition: indiproperties.cpp:59
INDI::Properties::const_reference
std::deque< INDI::Property >::const_reference const_reference
Definition: indiproperties.h:39
INDI::Properties::clear
void clear()
Definition: indiproperties.cpp:53