1 #ifndef SIGCXX_MARSHALLER_H
2 #define SIGCXX_MARSHALLER_H
3 #include <sigc++/sigc++config.h>
5 #ifndef SIGC_CXX_PARTIAL_SPEC
6 #include <sigc++/slot.h>
9 #ifndef SIGC_CXX_INT_CTOR
14 #include <sigc++/thread.h>
17 #ifdef SIGC_CXX_NAMESPACES
24 All classes used to marshal return values should have the following
28 // both typedefs must be defined.
30 typedef Type2 OutType;
33 // Return final return code.
36 // Captures return codes and returns TRUE to stop emittion.
37 bool marshal(const InType&);
42 It is not necessary for the InType to match the OutType.
43 This is to allow for things like list capturing.
47 /*******************************************************************
49 *******************************************************************/
51 // A struct that holds an flag for determining
52 // if the return value is to be ignored.
53 class LIBSIGC_API RetCode
56 static int check_ignore();
60 // Basic Marshal class.
66 #ifdef SIGC_CXX_PARTIAL_SPEC
69 typedef OutType OutType_;
71 typedef Trait<R>::type InType;
73 typedef InType OutType_;
77 OutType_& value() {return value_;}
79 static OutType_ default_value()
80 #ifdef SIGC_CXX_INT_CTOR
83 {OutType_ r; new (&r) OutType_(); return r;}
86 // This captures return values. Return TRUE to stop emittion process.
87 bool marshal(const InType& newval)
89 if (!RetCode::check_ignore()) value_=newval;
90 return 0; // continue emittion process
93 #ifdef SIGC_CXX_INT_CTOR
95 {RetCode::check_ignore();}
98 RetCode::check_ignore();
99 new (&value_) OutType_();
104 #ifdef SIGC_CXX_SPECIALIZE_REFERENCES
105 // Basic Marshal class.
106 template <typename R>
113 OutType value() {return value_;}
114 static OutType default_value() {return Default;}
117 // This captures return values. Return TRUE to stop emittion process.
118 bool marshal(InType newval)
120 if (!RetCode::check_ignore()) value_=&newval;
121 return 0; // continue emittion process
125 {RetCode::check_ignore();}
130 template <typename T> T Marshal<T&>::Default;
133 #ifdef SIGC_CXX_PARTIAL_SPEC
134 // dummy marshaller for void type.
147 // starts with a fixed value
148 template <class R,R initial>
155 OutType& value() {return value_;}
156 static OutType default_value() { return initial; }
158 bool marshal(const InType& newval)
160 if (!RetCode::check_ignore()) value_=newval;
161 return 0; // continue emittion process
166 {RetCode::check_ignore();}
178 OutType& value() {return value_;}
179 static OutType default_value()
180 #ifdef SIGC_CXX_INT_CTOR
183 {R r; new (&r) R(); return r;}
186 bool marshal(const InType& newval)
189 return 0; // continue emittion process
193 #ifdef SIGC_CXX_INT_CTOR
205 #ifdef SIGC_CXX_NAMESPACES