// Book.pp // // Created by Cristina Videira Lopes on 12/20/94. // // This file contains the set of propagation patterns whose source vertex // is the Book class; the operations defined here apply to objects // of this class. These are the current propagation patterns: // // *operation* void assemble (Title* t, Author* a, Publisher* p, Year* y, // Subject* s, ISBN* isbn, Copy_List* cl) // *operation* void create (DemString* ts, DemString* as, DemString* ps, // DemNumber* yn, DemString* ss, DemNumber* isbnn, // int n_copies) // *operation* Copy* search_copy (int key) // // // *operation* void assemble (Title* t, Author* a, Publisher* p, Year* y, // Subject* s, ISBN* isbn, Copy_List* cl) // // Assemble a book, given its parts. // *operation* void assemble (Title* t, Author* a, Publisher* p, Year* y, Subject* s, ISBN* isbn, Copy_List* cl) *wrapper* Book *prefix* (@ this->set_title (t); this->set_author (a); this->set_publisher (p); this->set_year (y); this->set_subject (s); this->set_isbn (isbn); this->set_copy_list (cl); @) // // *operation* void create (DemString* ts, DemString* as, DemString* ps, // DemNumber* yn, DemString* ss, DemNumber* isbnn, // int n_copies) // // Create the several parts of a book, given generic information. // *operation* void create (DemString* ts, DemString* as, DemString* ps, DemNumber* yn, DemString* ss, DemNumber* isbnn, int n_copies) *wrapper* Book *prefix* (@ int i; Copy *c; Title *t = new Title; t->set_t (ts); Author *a = new Author; a->set_a (as); Publisher *p = new Publisher; p->set_p (ps); Year *y = new Year; y->set_y (yn); Subject *s = new Subject; s->set_s (ss); ISBN *isbn = new ISBN; isbn->set_n (isbnn); Copy_List *cl = new Copy_List; for (i = 0; i < n_copies; i++) { c = new Copy; c->set_n (new DemNumber (i)); c->set_borrower (NULL); cl->append (c); } this->assemble (t, a, p, y, s, isbn, cl); @) // // *operation* Copy* search_copy (int key) // // search a given copy of the book, given a key (copy number) // *operation* Copy* search_copy (int key) *init* (@ NULL @) *traverse* *from* Book *to-stop* Copy *wrapper* ~> Copy_List, Copy *prefix* (@ if (return_val != NULL) return; @) *wrapper* Copy *prefix* (@ if (*this->get_n() == key) return_val = this; @)