LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2003, 08:25 PM   #1
bretzeltux
LQ Newbie
 
Registered: Oct 2003
Location: Montreal, Canada
Distribution: Fedora Core 2
Posts: 23

Rep: Reputation: 15
Post Event driven object-to-object: C++ template class mecanism ( NOT STL or STDC++)


Hi there, ( excuse my funny english :-)

I am to write ( re-re-rewrite/re-re-rethink like hell) yet another ncurses
based UI library. - Not the topic of my question though...

I am very well confortable with the drawing stuff and objects infrastructures...

Where I am stuck is about the object-to-object events relation.
Here below is a bit of code of the model I would want to create:

Code:
template < typename ClientClass, typename eventClass >
class ConnexionEvent{
     ...
 public:
     typedef int (ClientClass::*pCallbackT)(eventClass*);
     pCallbackT method;
     ConnexionEvent(pCallbackT classInstanceMethod, ...blah){
         method = classInstanceMethod;
         ...blah
     }
     ...
};
Notice the point:
Code:
   ...
   typedef int (ClientClass::*pCallbackT)(eventClass*);
I sware this code compile without errors...

My limited knowledge of C++ template programming prevents me to implement a consistent container class to hold a list or map or whatever ; thus a common place into where I could retreive an instance of that ConnexionEvent<... , ...> node.

That is. My whish is to be able to call directly the client'method of the actual object instance for a particular event class...

I thought of a std::map<objclass*, void*, lessclass> containing ConnexionEvent<objclass,evclass> address as void*... I can't try it right now since my computer is now out of reach

BTW: I whish the gnu gcc C++ conceptors would/could implement something similar to the Trolltech's QT signal/slot ( moc ) so geniously straitforward mecanism

Tell me if it is impossible or if there are known solutions...
Thanks,
Bretzel

Last edited by bretzeltux; 12-22-2003 at 08:27 PM.
 
Old 12-23-2003, 09:12 AM   #2
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
Quote:
Here below is a bit of code of the model I would want to create:
I am afraid that you will have to give a bit more detail about the model ... I am not clear where ConnexionEvent fits in to your model.

Quote:
... something similar to the Trolltech's QT signal/slot ( moc ) so geniously straitforward mecanism
Go to http://libsigc.sourceforge.net/ and you will find an excellent template based example of a signal / slot mechanism.

Last edited by dakensta; 12-23-2003 at 09:13 AM.
 
Old 12-23-2003, 03:45 PM   #3
bretzeltux
LQ Newbie
 
Registered: Oct 2003
Location: Montreal, Canada
Distribution: Fedora Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
libsigc++ -- DOH!!!!

Dakensta, I really thank you for your advice. You know what ? I have this package installed on my linux box ( mdk9.2; even the devel pckg ) and I did not notice that it does exactly what I need!!

Thus forget my model, i have to say I did not yet read docs of libsigc++ but I am really confident that it is what I need (regaring what I read on the at the URL) then I gonna be advancing into my prj very fast after beeing confortable with that lib...


W00t!

Thank you again
Bretzel
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass object variable to anothor class in JAVA hus Programming 2 05-11-2005 05:04 AM
Talk to an object in a diferent class bastl Programming 9 03-17-2005 02:36 PM
C++ class-object? shivaligupta Programming 2 01-06-2005 03:25 AM
how to const_cats a template object? markhod Programming 8 11-17-2004 05:31 AM
compile error while returning STL iterator as object * rameshmiraje Programming 2 06-20-2004 02:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration