InspIRCd  3.0
modechange.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2014 Attila Molnar <[email protected]>
5  *
6  * This file is part of InspIRCd. InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
20 #pragma once
21 
22 namespace Modes
23 {
24  struct Change;
25  class ChangeList;
26 }
27 
31 {
32  bool adding;
33  ModeHandler* mh;
34  std::string param;
35 
41  Change(ModeHandler* handler, bool add, const std::string& parameter)
42  : adding(add)
43  , mh(handler)
44  , param(parameter)
45  {
46  }
47 };
48 
52 {
53  public:
54  typedef std::vector<Change> List;
55 
59  void push(const Modes::Change& change)
60  {
61  items.push_back(change);
62  }
63 
68  void push(List::const_iterator first, List::const_iterator last)
69  {
70  items.insert(items.end(), first, last);
71  }
72 
78  void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
79  {
80  items.push_back(Change(mh, adding, param));
81  }
82 
87  void push_add(ModeHandler* mh, const std::string& param = std::string())
88  {
89  push(mh, true, param);
90  }
91 
96  void push_remove(ModeHandler* mh, const std::string& param = std::string())
97  {
98  push(mh, false, param);
99  }
100 
103  void clear() { items.clear(); }
104 
108  bool empty() const { return items.empty(); }
109 
113  List::size_type size() const { return items.size(); }
114 
118  const List& getlist() const { return items; }
119 
123  List& getlist() { return items; }
124 
125  private:
126  List items;
127 };
void push(ModeHandler *mh, bool adding, const std::string &param=std::string())
Definition: modechange.h:78
Definition: mode.h:95
List::size_type size() const
Definition: modechange.h:113
Definition: modechange.h:22
void push_remove(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:96
const List & getlist() const
Definition: modechange.h:118
Definition: modechange.h:30
void push(const Modes::Change &change)
Definition: modechange.h:59
void clear()
Definition: modechange.h:103
void push(List::const_iterator first, List::const_iterator last)
Definition: modechange.h:68
bool empty() const
Definition: modechange.h:108
List & getlist()
Definition: modechange.h:123
void push_add(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:87
Definition: modechange.h:51
Change(ModeHandler *handler, bool add, const std::string &parameter)
Definition: modechange.h:41