/*! \warning notification is sent before the copy constructor has
a chance of actually change the data members. Therefore, observers whose update() method tries to use their observables will not see the updated values. It is suggested that the update() method just raise a flag in order to trigger a later recalculation. */ inline Observable& Observable::operator=(const Observable& o) { // as above, the observer set is not copied. Moreover, // observers of this object must be notified of the change if (&o != this) notifyObservers(); return *this; } Question 1> Why the doc says that "notification is sent before the copy constructor has a chance of actually change the data members"? Question 2> Since the operator= doesn't modify the current object(this), why we should call notifyObservers()? Thank you ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Q1> I suppose because this is a base class not meant to be used directly, but only through derived classes. The default copy constructor _of the derived class_ first copies the base object, thus calling Observable::operator=, then copies the derived object’s data members. Q2> The base object isn’t modified (because the class has no actual content that should be updated), but the derived object is. Gerardo Da: Mike Jake [mailto:[hidden email]] /*! \warning notification is sent before the copy constructor has
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Yes, that's it.
Luigi On Thu, May 31, 2012 at 9:04 AM, Ballabio Gerardo <[hidden email]> wrote: > Q1> I suppose because this is a base class not meant to be used directly, > but only through derived classes. The default copy constructor _of the > derived class_ first copies the base object, thus calling > Observable::operator=, then copies the derived object’s data members. > > Q2> The base object isn’t modified (because the class has no actual content > that should be updated), but the derived object is. > > > > Gerardo > > > > > > Da: Mike Jake [mailto:[hidden email]] > Inviato: mercoledì 30 maggio 2012 18.02 > A: [hidden email] > Oggetto: [Quantlib-users] Questions about the implementation of Observable& > Observable::operator=(const Observable& o) > > > > /*! \warning notification is sent before the copy constructor has > a chance of actually change the data > members. Therefore, observers whose update() method > tries to use their observables will not see the > updated values. It is suggested that the update() > method just raise a flag in order to trigger > a later recalculation. > */ > inline Observable& Observable::operator=(const Observable& o) { > // as above, the observer set is not copied. Moreover, > // observers of this object must be notified of the change > if (&o != this) > notifyObservers(); > return *this; > } > > > Question 1> Why the doc says that "notification is sent before the copy > constructor has a chance of actually change the data members"? > > Question 2> Since the operator= doesn't modify the current object(this), why > we should call notifyObservers()? > > Thank you > > > > > Banca Profilo S.p.A. > Corso Italia, 49 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057 > Capitale Sociale Euro 136.794.106,00 i.v. > Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - > [hidden email] > Iscritta all’Albo delle Banche e dei Gruppi bancari > Aderente al Fondo Interbancario di Tutela dei depositi > Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario > Finanziario > Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di > direzione e coordinamento di Arepo BP S.p.A. > > > DISCLAIMER: > The information transmitted may contain confidential and/or privileged > material. > Any review, retransmission, dissemination or other use of, or taking of any > action in reliance upon, > this information by persons or entities other than the intended recipient is > prohibited. > If you received this in error, please contact the sender and delete the > material from any computer. > > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |