guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gproplist.hpp
1 //
2 // Property List
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef GuitPropList_hpp
9 #define GuitPropList_hpp
10 #include <forward_list>
11 #include <gprop.hpp>
12 #include <gptr.hpp>
13 namespace guit {
14 
17 class GPropList {
18 public:
19  using iterator = std::forward_list<gptr<GProp>>::iterator;
20 
21  GPropList() = default;
22  GPropList(std::initializer_list<gptr<GProp>> prop_list);
23  GPropList(GString const& prop_list);
24 
25  auto& list() {return list_;}
26  const auto& list() const {return list_;}
27  size_t size() const;
28  bool empty() const {return list_.empty();}
29 
30  iterator begin() {return list_.begin();}
31  iterator before_begin() {return list_.before_begin();}
32  iterator end() {return list_.end();}
33 
34  auto begin() const {return list_.begin();}
35  auto before_begin() const {return list_.before_begin();}
36  auto end() const {return list_.end();}
37 
38  GProp* findProp(GPropType&) const;
39  template <class T>
40  T* findProp() const {return dynamic_cast<T*>(findProp(T::Class()));}
41  GProp* findProp(std::function<bool(GProp&)>& predicate) const;
42 
45  void addReplace(GProp&, Gadget*);
46 
49  void addBegin(GProp&);
50  void addBegin(GPropList const&);
51  void addEnd(GProp&);
52  void addEnd(GPropList const&);
54 
55  bool remove(Gadget*, std::function<bool(GProp&)> pred);
56  bool remove(Gadget*, GProp&);
57  bool remove(Gadget*, GPropType&);
58  void removeAll(Gadget*);
59 
60  void fire(GEvent&);
61  void fire(GObject* aux);
62 
64  class GNotifier* findNotifier(void* obj);
65 
67  void removeNotifiers(void* obj);
68 
69 //private:
70  friend class Gadget;
71  friend class GVarProp;
72  std::forward_list<gptr<GProp>> list_;
73 };
74 
75 }
76 #endif