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 
61  void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
62  {
63  items.push_back(Change(mh, adding, param));
64  }
65 
70  void push_add(ModeHandler* mh, const std::string& param = std::string())
71  {
72  push(mh, true, param);
73  }
74 
79  void push_remove(ModeHandler* mh, const std::string& param = std::string())
80  {
81  push(mh, false, param);
82  }
83 
86  void clear() { items.clear(); }
87 
91  bool empty() const { return items.empty(); }
92 
96  List::size_type size() const { return items.size(); }
97 
101  const List& getlist() const { return items; }
102 
106  List& getlist() { return items; }
107 
108  private:
109  List items;
110 };
void push(ModeHandler *mh, bool adding, const std::string &param=std::string())
Definition: modechange.h:61
Definition: mode.h:95
List::size_type size() const
Definition: modechange.h:96
Definition: modechange.h:22
void push_remove(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:79
const List & getlist() const
Definition: modechange.h:101
Definition: modechange.h:30
void clear()
Definition: modechange.h:86
bool empty() const
Definition: modechange.h:91
List & getlist()
Definition: modechange.h:106
void push_add(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:70
Definition: modechange.h:51
Change(ModeHandler *handler, bool add, const std::string &parameter)
Definition: modechange.h:41