A command-line client for interacting with "book" and "member" servers via XMLRPC calls. Servers were created by other students.

BookstoreCaller.h 2.8KB

    #ifndef __KAVAMA_FINAL_CALLER__ #define __KAVAMA_FINAL_CALLER__ #include <string> #include <vector> #include <map> #include <xmlrpc-c/base.hpp> #include <xmlrpc-c/client_simple.hpp> #include <stdlib.h> // for atoi #include "BookType.h" #include "MemberType.h" class BookstoreCaller { private: std::string _memberFullAddress; std::string _memberAddress; int _memberPort; bool _isMemberUp; std::string _bookFullAddress; std::string _bookAddress; int _bookPort; bool _isBookUp; std::map<std::string, BookType> _books; std::map<std::string, MemberType> _members; xmlrpc_c::clientSimple _client; // // static std::string Method_BookAdd = "AddBook"; // static std::string Method_BookUpdate = "UpdateBook"; // static std::string Method_BookDelete = "DelBook"; // static std::string Method_BookLookup = "SearchBook"; // static std::string Method_BookList = "BookList"; // static std::string Method_MemberAdd = "AddMember"; // static std::string Method_MemberUpdate = "UpdateMember"; // static std::string Method_MemberDelete = "DelMember"; // static std::string Method_MemberLookup = "SearchMember"; // static std::string Method_MemberList = "MemberList"; public: BookstoreCaller(); BookstoreCaller(std::string MemberAddress, std::string MemberPort, std::string BookAddress, std::string BookPort); // MemberConnect - Perform a member list lookup to test if the member server is up // Called from parameterized constructor // Pre: Address and Port must be set for Member Server prior to usage. // Post: Member list is set to _members and IsMemberServerUp() returns true bool MemberConnect(); // BookConnect - Perform a book list lookup to test if the book server is up // Called from parameterized constructor // Pre: Address and Port must be set for Book Server prior to usage. // Post: Book list is set to _books and IsBookServerUp() returns true bool BookConnect(); std::string MemberFullAddress(); std::string MemberAddress(); int MemberPort(); bool IsMemberServerUp(); std::string BookFullAddress(); std::string BookAddress(); int BookPort(); bool IsBookServerUp(); // IsReady - Is the caller ready to be used for both Book and Member server? bool IsReady(); std::map<std::string, MemberType> Members(); int MemberCount(); std::map<std::string, BookType> Books(); int BookCount(); // Methods to call XMLRPC-C Bookstore Server // Books bool AddBook(BookType); bool UpdateBook(BookType); bool DeleteBook(std::string ISBN); bool DeleteBook(BookType); BookType LookupBook(std::string ISBN); const std::map<std::string, BookType> BookList(); // Members bool AddMember(MemberType); bool UpdateMember(MemberType); bool DeleteMember(std::string ID); bool DeleteMember(MemberType); MemberType LookupMember(std::string ISBN); const std::map<std::string, MemberType> MemberList(); }; #endif