2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
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.
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
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/>.
28 /** A single mode to be changed
37 * @param handler Mode handler
38 * @param add True if this mode is being set, false if removed
39 * @param parameter Mode parameter
41 Change(ModeHandler* handler, bool add, const std::string& parameter)
49 /** A list of mode changes that can be applied on a Channel or User
51 class Modes::ChangeList
54 typedef std::vector<Change> List;
56 /** Add a new mode to be changed to this ChangeList
57 * @param handler Mode handler
58 * @param add True if this mode is being set, false if removed
59 * @param parameter Mode parameter
61 void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
63 items.push_back(Change(mh, adding, param));
66 /** Add a new mode to this ChangeList which will be set on the target
67 * @param handler Mode handler
68 * @param parameter Mode parameter
70 void push_add(ModeHandler* mh, const std::string& param = std::string())
72 push(mh, true, param);
75 /** Add a new mode to this ChangeList which will be unset from the target
76 * @param handler Mode handler
77 * @param parameter Mode parameter
79 void push_remove(ModeHandler* mh, const std::string& param = std::string())
81 push(mh, false, param);
84 /** Remove all mode changes from this stack
86 void clear() { items.clear(); }
88 /** Checks whether the ChangeList is empty, equivalent to (size() != 0).
89 * @return True if the ChangeList is empty, false otherwise.
91 bool empty() const { return items.empty(); }
93 /** Get number of mode changes in this ChangeList
94 * @return Number of mode changes in this ChangeList
96 List::size_type size() const { return items.size(); }
98 /** Get the list of mode changes in this ChangeList
99 * @return List of modes added to this ChangeList
101 const List& getlist() const { return items; }
103 /** Get the list of mode changes in this ChangeList
104 * @return List of modes added to this ChangeList
106 List& getlist() { return items; }