Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Observer design pattern in C++

Is the observer design pattern already defined in STL (Like the java.util.Observer and java.util.Observable in Java) ?

like image 932
Lucas Avatar asked Feb 08 '10 21:02

Lucas


2 Answers

No, but Boost.Signals2 gives you something similar.

like image 174
David Seiler Avatar answered Nov 11 '22 23:11

David Seiler


As far as my knowledge goes in C++, STL doesn't have an implementation for Observer pattern. There was a proposal for Signal/Slot for standard library in TR2 though.

There are plenty of libraries which provides implementation for Observer pattern Qt library being one of the pioneers. The boost library has an implementation (see Boost::Signals & Boost::Signals2).

The Poco C++ library has a neat implementation of the observer pattern (see NotificationCenter).

libsigc++, cpp-events are some of the other libraries that provide signal/slot implementations.

like image 28
agupta666 Avatar answered Nov 11 '22 21:11

agupta666