[sigc] retype and hide_return not included



hello all,
i'm trying to write a little example program in which i use all of the various ways to adapt a slot to a signal, but when i try to use hide_return and retype in libsigc++-1.2, their definitions don't seem to be found in the header files included through including sigc++.h. i've attached my (self contained) file. i tried explicitly includeing retype.h, but that didn't help matters. can anyone give me some pointers about what i'm doing wrong?

thanks!
-tim
#include <iostream>
#include <sigc++/sigc++.h>

using namespace SigC;
using namespace std;

void callback_void_return_no_parameters()
{
  cout << "callback_void_return_no_parameters()" << endl;
}

void callback_void_return_int_parameter(int i)
{
  cout << "callback_void_return_int_parameter(" << i << ")" << endl;
}

float callback_float_return_int_parameter(int i)
{
  return static_cast<float>(i) / 2;
}

class SigCDerivedClass : public SigC::Object
{
/**
  This is a sample class used below to show how to connect a signal to
  non-static functions belonging to a class.

  In order to connect a signal to a slot made from a non-static function
  which is a member of a class, that class must derive from SigC::Object.
*/
  public:
    SigCDerivedClass() : SigC::Object() {};

    // You will get a compiler error if you don't impliment the destructor
    // in a class deriving from SigC::Object.
    ~SigCDerivedClass() {};

    void NonStaticFunction()
        { cout << "SigCDerivedClass::NonStaticFunction()" << endl; };
};

class NonSigCDerivedClass
{
/**
*/
  public:
    NonSigCDerivedClass();

    static void StaticClassFunction()
        { cout << "NonSigCDerivedClass::StaticClassFunction()" << endl; };
};


main()
{
  SigCDerivedClass object;
  Connection connection;

  Signal0<void> signal_void_return_no_parameters;
  signal_void_return_no_parameters.connect(
      slot(&callback_void_return_no_parameters) );
  signal_void_return_no_parameters.connect(
      slot(&NonSigCDerivedClass::StaticClassFunction) );
  signal_void_return_no_parameters.connect(
      slot(object, &SigCDerivedClass::NonStaticFunction) );
  signal_void_return_no_parameters.connect(
      bind(slot(&callback_void_return_int_parameter), 10) );
  signal_void_return_no_parameters();
  cout << endl;

  Signal1<void, int> signal_void_return_int_parameter;
  signal_void_return_int_parameter.connect(
      slot(&callback_void_return_int_parameter) ); 
  signal_void_return_int_parameter.connect(
      hide<int>(slot(&callback_void_return_no_parameters)) );
  signal_void_return_int_parameter.connect(
      hide_return(slot(&callback_float_return_int_parameter) );
  signal_void_return_int_parameter(1);
  cout << endl;

  Signal1<float, int> signal_float_return_int_parameter;
  connection = 
      signal_float_return_int_parameter.connect(
          slot(&callback_float_return_int_parameter)
      );
  cout << "signal_float_return_int_parameter(1) returns "
       << signal_float_return_int_parameter(1) << endl;
  connection.disconnect();
  signal_float_return_int_parameter.connect(
      bind_return<float>(slot(&callback_void_return_int_parameter), 0.0) );
  cout << "signal_float_return_int_parameter(3) with bind_return to "
       << "callback_void_return_int_parameter returns "
        << signal_float_return_int_parameter(3) << endl;
  cout << endl;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]