Unity Scopes API
FilterState.h
1 /*
2  * Copyright (C) 2013 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/Variant.h>
22 #include <unity/util/DefinesPtrs.h>
23 #include <memory>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 class FilterBase;
32 
33 namespace internal
34 {
35 class FilterStateImpl;
36 class FilterBaseImpl;
37 }
38 
46 class FilterState final
47 {
48 public:
50  UNITY_DEFINES_PTRS(FilterState);
51 
52  ~FilterState();
53  VariantMap serialize() const;
54  static FilterState deserialize(VariantMap const& var);
56 
60  FilterState();
61 
65  //{@
66  FilterState(FilterState const& other);
68  FilterState& operator=(FilterState const& other);
69  FilterState& operator=(FilterState&& other);
71 
76  bool has_filter(std::string const& id) const;
77 
82  void remove(std::string const& id);
83 
84 private:
85  FilterState(internal::FilterStateImpl *pimpl);
86  std::unique_ptr<internal::FilterStateImpl> p;
87  friend class internal::FilterBaseImpl;
88  friend class internal::FilterStateImpl;
89 };
90 
91 } // namespace scopes
92 
93 } // namespace unity
Top-level namespace for all things Unity-related.
Definition: Version.h:49
bool has_filter(std::string const &id) const
Check if state for the given filter has been stored.
Definition: FilterState.cpp:71
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:38
Definition: ActionMetadata.h:31
Captures state of multiple filters.
Definition: FilterState.h:46
FilterState()
Constructs a an empty filter state instance.
Definition: FilterState.cpp:29