2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
5 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class CoreExport dynamic_reference_base : public interfacebase, public insp::intrusive_list_node<dynamic_reference_base>
31 ServiceProvider* value;
34 dynamic_reference_base(Module* Creator, const std::string& Name);
35 ~dynamic_reference_base();
36 inline const std::string& GetProvider() { return name; }
37 void SetProvider(const std::string& newname);
39 operator bool() { return (value != NULL); }
40 static void reset_all();
43 inline void dynamic_reference_base::check()
46 throw ModuleException("Dynamic reference to '" + name + "' failed to resolve");
50 class dynamic_reference : public dynamic_reference_base
53 dynamic_reference(Module* Creator, const std::string& Name)
54 : dynamic_reference_base(Creator, Name) {}
56 inline T* operator->()
59 return static_cast<T*>(value);
69 class dynamic_reference_nocheck : public dynamic_reference_base
72 dynamic_reference_nocheck(Module* Creator, const std::string& Name)
73 : dynamic_reference_base(Creator, Name) {}
77 return static_cast<T*>(value);
87 class ChanModeReference : public dynamic_reference_nocheck<ModeHandler>
90 ChanModeReference(Module* mod, const std::string& modename)
91 : dynamic_reference_nocheck<ModeHandler>(mod, "mode/" + modename) {}
94 class UserModeReference : public dynamic_reference_nocheck<ModeHandler>
97 UserModeReference(Module* mod, const std::string& modename)
98 : dynamic_reference_nocheck<ModeHandler>(mod, "umode/" + modename) {}