Unity Scopes API
RangeInputFilter.h
1 /*
2  * Copyright (C) 2015 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/FilterBase.h>
22 #include <unity/scopes/Variant.h>
23 #include <unity/scopes/FilterGroup.h>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 class FilterState;
32 
33 namespace internal
34 {
35 class RangeInputFilterImpl;
36 }
37 
47 class UNITY_API RangeInputFilter : public FilterBase
48 {
49 public:
51  UNITY_DEFINES_PTRS(RangeInputFilter);
53 
64  static RangeInputFilter::SPtr create(std::string const& id,
65  std::string const& start_prefix_label, std::string const& start_postfix_label,
66  std::string const& central_label,
67  std::string const& end_prefix_label, std::string const& end_postfix_label);
68 
81  static RangeInputFilter::SPtr create(std::string const& id,
82  Variant const& default_start_value,
83  Variant const& default_end_value,
84  std::string const& start_prefix_label, std::string const& start_postfix_label,
85  std::string const& central_label,
86  std::string const& end_prefix_label, std::string const& end_postfix_label);
87 
99  static RangeInputFilter::SPtr create(std::string const& id,
100  std::string const& start_prefix_label, std::string const& start_postfix_label,
101  std::string const& central_label,
102  std::string const& end_prefix_label, std::string const& end_postfix_label, FilterGroup::SCPtr const& group);
103 
117  static RangeInputFilter::SPtr create(std::string const& id,
118  Variant const& default_start_value,
119  Variant const& default_end_value,
120  std::string const& start_prefix_label, std::string const& start_postfix_label,
121  std::string const& central_label,
122  std::string const& end_prefix_label, std::string const& end_postfix_label,
123  FilterGroup::SCPtr const& group);
124 
129  std::string start_prefix_label() const;
130 
135  std::string start_postfix_label() const;
136 
141  std::string end_prefix_label() const;
142 
147  std::string end_postfix_label() const;
148 
153  std::string central_label() const;
154 
162  Variant default_start_value() const;
163 
171  Variant default_end_value() const;
172 
179  bool has_start_value(FilterState const& filter_state) const;
180 
187  bool has_end_value(FilterState const& filter_state) const;
188 
195  double start_value(FilterState const& filter_state) const;
196 
203  double end_value(FilterState const& filter_state) const;
204 
218  void update_state(FilterState& filter_state, Variant const& start_value, Variant const& end_value) const;
219 
231  static void update_state(FilterState& filter_state, std::string const& filter_id, Variant const& start_value, Variant const& end_value);
232 
233 private:
234  RangeInputFilter(internal::RangeInputFilterImpl*);
235  internal::RangeInputFilterImpl* fwd() const;
236  friend class internal::RangeInputFilterImpl;
237 };
238 
239 } // namespace scopes
240 
241 } // namespace unity
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:57
Base class for all implementations of filters.
Definition: FilterBase.h:47
Top-level namespace for all things Unity-related.
Definition: Version.h:49
A range filter allows a start and end value to be entered by the user.
Definition: RangeInputFilter.h:47
Definition: ActionMetadata.h:31
Stores the state of multiple filters.
Definition: FilterState.h:46