~ubuntu-branches/ubuntu/wily/cxxtools/wily-proposed

« back to all changes in this revision

Viewing changes to demo/signals.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2008-06-16 12:24:28 UTC
  • mfrom: (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616122428-7bllgyt1358u779r
Tags: 1.4.8-2
Made libcxxtools-dev depend on libcxxtools6, not libcxxtools5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cxxtools/signals.h>
 
2
#include <iostream>
 
3
 
 
4
int function()
 
5
{
 
6
  std::cout << "function called." << std::endl;
 
7
  return 0;
 
8
}
 
9
 
 
10
struct Object : public cxxtools::Connectable
 
11
{
 
12
  bool method()
 
13
  {
 
14
    std::cout << "Object::method called." << std::endl;
 
15
    return true;
 
16
  }
 
17
 
 
18
  char constMethod() const
 
19
  {
 
20
    std::cout << "Object::constMethod called." << std::endl;
 
21
    return 'r';
 
22
  }
 
23
 
 
24
  static std::string staticMethod()
 
25
  {
 
26
    std::cout << "Object::staticMethod called." << std::endl;
 
27
    return "test";
 
28
  }
 
29
};
 
30
 
 
31
 
 
32
int main(int argc, char* argv[])
 
33
{
 
34
  try
 
35
  {
 
36
    Object obj;
 
37
    cxxtools::Signal<> signal;
 
38
    signal.connect( cxxtools::slot(function) );
 
39
    signal.connect( cxxtools::slot(obj, &Object::method) );
 
40
    signal.connect( cxxtools::slot(obj, &Object::constMethod) );
 
41
    signal.connect( cxxtools::slot(&Object::staticMethod) );
 
42
 
 
43
    signal.send();
 
44
  }
 
45
  catch (const std::exception& e)
 
46
  {
 
47
    std::cerr << e.what() << std::endl;
 
48
    return 1;
 
49
  }
 
50
}