I've two C++ classes with a relation: a container class which has a list of items. For example a library has got many books. The classes are the library and the book.
Now from the external world I have to create, update and delete books. In addition there other classes that are interested to know when an event on a book happens and these (observers) instances can be created at run-time.
Now I've got different ways to proceed:
1) Use always the container to do the operation: central point of management but I have to create couples of methods for example setTitle(bookID) that call setTitle() on the book, bad;
2) Use a getBook() on the container to return a reference of the book, allow the modification, at this point I have to use a commit method to notify the container which can notify the observer but in this way the pattern doesn't force a "commit", I mean if the external caller doesn't call commit() I loose :)
3) Use a getBook() on the container to return a copy of the book and an update method of the container to overwrite the book, central point of management again but the book if big is a problem, a lot of copies are really bad.
Any tips? Is there any pattern that covers this use case?