Skip to main content
corrected spelling
Source Link
rucamzu
  • 515
  • 2
  • 10

Be aware that what you want to implement isyou're accurately describing the observer design pattern, having yourgiven the domain model object asto be the subject and the views asto be observers. Note also that this isthe observer pattern implies a higher level of abstraction construct than a mere smart pointer, and that there is no direct conceptual correspondence between the two of them.

In order to implement itthis pattern, you must firstly ensure that all the involved views should(observers) implement a common interface (for example, for example by inheritance)inheriting a common base, whileabstract class. Then, the domain object would manage(subject) can proceed with managing a set of references (for example, smart pointers) to instances of that said observer interface, and notifying them all (bywhen required, by calling the appropriate interface methods) when required.

Smart pointers can be used in this scheme to implement the references managed by the subject.

Be aware that what you want to implement is the observer design pattern, having your domain model object as the subject and the views as observers. Note also that this is a higher level abstraction construct than a mere smart pointer, and there is no conceptual correspondence between them.

In order to implement it, all views should implement a common interface (for example, by inheritance), while the domain object would manage a set of references (for example, smart pointers) to instances of that interface, notifying them all (by calling the appropriate interface methods) when required.

Be aware that you're accurately describing the observer design pattern, given the domain model object to be the subject and the views to be observers. Note also that the observer pattern implies a higher level of abstraction than a smart pointer, and that there is no direct conceptual correspondence between the two of them.

In order to implement this pattern, you must firstly ensure that all the involved views (observers) implement a common interface, for example by inheriting a common base, abstract class. Then, the domain object (subject) can proceed with managing a set of references to instances of that said observer interface, and notifying them all when required, by calling the appropriate interface methods.

Smart pointers can be used in this scheme to implement the references managed by the subject.

Source Link
rucamzu
  • 515
  • 2
  • 10

Be aware that what you want to implement is the observer design pattern, having your domain model object as the subject and the views as observers. Note also that this is a higher level abstraction construct than a mere smart pointer, and there is no conceptual correspondence between them.

In order to implement it, all views should implement a common interface (for example, by inheritance), while the domain object would manage a set of references (for example, smart pointers) to instances of that interface, notifying them all (by calling the appropriate interface methods) when required.