]> git.lyx.org Git - lyx.git/blob - sigc++/doc/powerusers
export patch from Dekel
[lyx.git] / sigc++ / doc / powerusers
1 The following things are be available to powerusers.
2
3   - changing the return type of a slot
4   - changing the paramete types of slot
5   - signal overloading
6   - mixed type signals
7
8 =======================================================================
9 * Slot type changing
10
11 Slots can be made to change their input types based on a static function.
12
13 Example:
14
15   // write some conversion functions
16   int convert_mysignal_c(Callback1<int,const char*> *s,const string &str)
17     {return s->call(str.c_str());}
18   Slot1<int,const string&> myconvert(const Slot1<int,const char*> &s)
19     {return convert(s,convert_mysignal_c);}
20
21
22   Signal1<int,const string&> mysignal;
23   int foo(const char*);
24   mysignal.connect(myconvert(slot(foo));
25
26
27 * Signal overloading
28
29 One signal can have multiple behavior for a single signal name.  
30 This is done with multiple inheritance.
31
32 Example:
33
34   class MyClass
35     {
36       public:
37         class MySig 
38           :public Signal1<int,int>, 
39            public Signal1<void,double>
40          {} mysig;
41    } myclass;
42
43   int foo(int);
44   void foo2(double);
45   myclass.mysig.connect(slot(foo));
46   myclass.mysig.connect(slot(foo2));
47   myclass.mysig(1);   // calls foo
48   myclass.mysig(1.0); // calls foo2
49
50          
51
52 * Mixed type signals
53
54 A signal can be made to accept a wide group of slots with similar data
55 types.
56
57 Example:
58
59   class A
60     {
61
62      public:
63      class MySig: public Signal1<int,string&>
64        {
65           static int _mysig_convert(Callback1<int,const char*> *s,
66                                     const string &str)
67             {return s->call(str.c_str());}
68         public:
69           Connection connect(const Slot1<int,const char*> &s)
70             {return connect(convert(s,_mysig_convert));}
71        }  mysig;
72     };
73
74   int foo(const char* c);
75   int foo2(string& s);
76
77   mysig.connect(slot(foo));  // this is acceptable
78   mysig.connect(slot(foo2)); // this is also acceptable
79   string h="hello";
80   mysig(h);                  // calls both foo and foo2.
81
82
83 Still in works
84 ----------------
85 * Signal overloading over classes
86
87 This should be extendable accross different levels of a class.
88
89 Example: (details still in progress)
90
91   
92
93 * Signals with translation
94
95 Signals can be made to convert and proxy accross other systems.
96