00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef SLOTARG_H
00012 #define SLOTARG_H
00013
00014 #include <sigc++/functors/slot.h>
00015
00016 namespace cwidget
00017 {
00018 namespace util
00019 {
00020 template<typename T>
00021 class slotarg
00022 {
00023 bool hasslot;
00024 T theslot;
00025 public:
00026 slotarg(const T *slot)
00027 {
00028 if(slot)
00029 {
00030 theslot=*slot;
00031 hasslot=true;
00032 }
00033 else
00034 hasslot=false;
00035 }
00036 slotarg(const T &slot)
00037 :hasslot(true), theslot(slot)
00038 {
00039 }
00040
00041 template <typename S>
00042 operator slotarg<S>() const
00043 {
00044 if(hasslot)
00045 return slotarg<S>(theslot);
00046 else
00047 return slotarg<S>(NULL);
00048 }
00049
00050 operator bool() const {return hasslot;}
00051 const T & operator*() const {return theslot;}
00052 T & operator*() {return theslot;}
00053 };
00054
00055 typedef slotarg<sigc::slot0<void> > slot0arg;
00056
00057 template<typename T>
00058 slotarg<T> arg(const T &slot)
00059 {
00060 return slotarg<T>(slot);
00061 }
00062 }
00063 }
00064
00065 #endif