slot_container.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_core.h"
00035 #include "slot.h"
00036 #include "signal_v0.h"
00037 #include "signal_v1.h"
00038 #include "signal_v2.h"
00039 #include "signal_v3.h"
00040 #include "signal_v4.h"
00041 #include "signal_v5.h"
00042 #include <vector>
00043 
00056 class CL_API_CORE CL_SlotContainer
00057 {
00060 
00061 public:
00063         template<class SigClass>
00064         void connect(SigClass &sig, void (*func)())
00065         {
00066                 slots.push_back(sig.connect(func));
00067         }
00068 
00070         template<class SigClass, class Class>
00071         void connect(SigClass &sig, Class *self, void(Class::*func)())
00072         {
00073                 slots.push_back(sig.connect(self, func));
00074         }
00075 
00078         template<class SigClass, class UserData>
00079         void connect(SigClass &sig, void(*func)(UserData), UserData user_data)
00080         {
00081                 slots.push_back(sig.connect(func, user_data));
00082         }
00083 
00086         template<class SigClass, class Class, class UserData>
00087         void connect(SigClass &sig, Class *self, void(Class::*func)(UserData), UserData user_data)
00088         {
00089                 slots.push_back(sig.connect(self, func, user_data));
00090         }
00091 
00093         template<class SigClass, class Param1>
00094         void connect(SigClass &sig, void(*func)(Param1))
00095         {
00096                 slots.push_back(sig.connect(func));
00097         }
00098 
00100         template<class SigClass, class Class, class Param1>
00101         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1))
00102         {
00103                 slots.push_back(sig.connect(self, func));
00104         }
00105 
00108         template<class SigClass, class Param1, class UserData>
00109         void connect(SigClass &sig, void(*func)(Param1, UserData), UserData user_data)
00110         {
00111                 slots.push_back(sig.connect(func, user_data));
00112         }
00113 
00116         template<class SigClass, class Class, class Param1, class UserData>
00117         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, UserData), UserData user_data)
00118         {
00119                 slots.push_back(sig.connect(self, func, user_data));
00120         }
00121 
00123         template<class SigClass, class Param1, class Param2>
00124         void connect(SigClass &sig, void(*func)(Param1, Param2))
00125         {
00126                 slots.push_back(sig.connect(func));
00127         }
00128 
00130         template<class SigClass, class Class, class Param1, class Param2>
00131         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2))
00132         {
00133                 slots.push_back(sig.connect(self, func));
00134         }
00135 
00138         template<class SigClass, class Param1, class Param2, class UserData>
00139         void connect(SigClass &sig, void(*func)(Param1, Param2, UserData), UserData user_data)
00140         {
00141                 slots.push_back(sig.connect(func, user_data));
00142         }
00143 
00146         template<class SigClass, class Class, class Param1, class Param2, class UserData>
00147         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, UserData), UserData user_data)
00148         {
00149                 slots.push_back(sig.connect(self, func, user_data));
00150         }
00151 
00153         template<class SigClass, class Param1, class Param2, class Param3>
00154         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3))
00155         {
00156                 slots.push_back(sig.connect(func));
00157         }
00158 
00160         template<class SigClass, class Class, class Param1, class Param2, class Param3>
00161         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3))
00162         {
00163                 slots.push_back(sig.connect(self, func));
00164         }
00165 
00168         template<class SigClass, class Param1, class Param2, class Param3, class UserData>
00169         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3, UserData), UserData user_data)
00170         {
00171                 slots.push_back(sig.connect(func, user_data));
00172         }
00173 
00176         template<class SigClass, class Class, class Param1, class Param2, class Param3, class UserData>
00177         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3, UserData), UserData user_data)
00178         {
00179                 slots.push_back(sig.connect(self, func, user_data));
00180         }
00181 
00183         template<class SigClass, class Param1, class Param2, class Param3, class Param4>
00184         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3, Param4))
00185         {
00186                 slots.push_back(sig.connect(func));
00187         }
00188 
00190         template<class SigClass, class Class, class Param1, class Param2, class Param3, class Param4>
00191         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3, Param4))
00192         {
00193                 slots.push_back(sig.connect(self, func));
00194         }
00195 
00198         template<class SigClass, class Param1, class Param2, class Param3, class Param4, class UserData>
00199         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3, Param4, UserData user_data), UserData user_data)
00200         {
00201                 slots.push_back(sig.connect(func, user_data));
00202         }
00203 
00206         template<class SigClass, class Class, class Param1, class Param2, class Param3, class Param4, class UserData>
00207         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3, Param4, UserData user_data), UserData user_data)
00208         {
00209                 slots.push_back(sig.connect(self, func, user_data));
00210         }
00211 
00213         template<class SigClass, class Param1, class Param2, class Param3, class Param4, class Param5>
00214         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3, Param4, Param5))
00215         {
00216                 slots.push_back(sig.connect(func));
00217         }
00218 
00220         template<class SigClass, class Class, class Param1, class Param2, class Param3, class Param4, class Param5>
00221         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3, Param4, Param5))
00222         {
00223                 slots.push_back(sig.connect(self, func));
00224         }
00225 
00228         template<class SigClass, class Param1, class Param2, class Param3, class Param4, class Param5, class UserData>
00229         void connect(SigClass &sig, void(*func)(Param1, Param2, Param3, Param4, Param5, UserData user_data), UserData user_data)
00230         {
00231                 slots.push_back(sig.connect(func, user_data));
00232         }
00233 
00236         template<class SigClass, class Class, class Param1, class Param2, class Param3, class Param4, class Param5, class UserData>
00237         void connect(SigClass &sig, Class *self, void(Class::*func)(Param1, Param2, Param3, Param4, Param5, UserData user_data), UserData user_data)
00238         {
00239                 slots.push_back(sig.connect(self, func, user_data));
00240         }
00241 
00243         template<class SigClass, class Functor>
00244         void connect_functor(SigClass &sig, const Functor &functor)
00245         {
00246                 slots.push_back(sig.connect_functor(functor));
00247         }
00248 
00249 private:
00250         std::vector<CL_Slot> slots;
00252 };
00253 
00254