Commit 66104142 by Andrew Dahl

Added Parameters for Clients & Servers -- Cleaned Up Book Classes

parent 6193e6f4
...@@ -216,38 +216,3 @@ bool Book::setYear(int Year) ...@@ -216,38 +216,3 @@ bool Book::setYear(int Year)
return outs; return outs;
} }
bool Book::operator >= (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator == (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator <= (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator < (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator != (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator > (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
...@@ -70,13 +70,16 @@ public: ...@@ -70,13 +70,16 @@ public:
string getAuthor(int num) const; string getAuthor(int num) const;
/*
* Unneeded For BookServer Implementation
*
bool operator >= (const Book & rhs) const; bool operator >= (const Book & rhs) const;
bool operator == (const Book & rhs) const; bool operator == (const Book & rhs) const;
bool operator <= (const Book & rhs) const; bool operator <= (const Book & rhs) const;
bool operator < (const Book & rhs) const; bool operator < (const Book & rhs) const;
bool operator != (const Book & rhs) const; bool operator != (const Book & rhs) const;
bool operator > (const Book & rhs) const; bool operator > (const Book & rhs) const;
*/
}; };
#endif /* BOOK_H_ */ #endif /* BOOK_H_ */
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <cstdlib> #include <cstdlib>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <xmlrpc-c/girerr.hpp> #include <xmlrpc-c/girerr.hpp>
...@@ -67,20 +68,29 @@ void printResult(bool ret) ...@@ -67,20 +68,29 @@ void printResult(bool ret)
cout << "False\n"; cout << "False\n";
} }
int main(int argc, char **) int main(int argc, char ** argv)
{ {
string hostname = "localhost";
string servPort = "";
if (argc-1 > 0) switch (argc)
{ {
cerr << "This program has no arguments" << endl; case 3:
exit(1); hostname = argv[2];
case 2:
servPort = argv[1];
break;
default:
cerr << "Usage: " << argv[0] << " <port> [hostname]\n";
return (1);
} }
try try
{ {
string URL = "http://" + hostname + ":" + servPort + "/RPC2";
BookHandler bookHandle; BookHandler bookHandle;
string const serverUrl("http://localhost:8081/RPC2"); string const serverUrl(URL);
string const addBook("addBook"); string const addBook("addBook");
string const deleteBook("deleteBook"); string const deleteBook("deleteBook");
string const searchBook("searchBook"); string const searchBook("searchBook");
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h>
#include <string> #include <string>
#include <xmlrpc-c/base.hpp> #include <xmlrpc-c/base.hpp>
...@@ -19,9 +20,16 @@ ...@@ -19,9 +20,16 @@
using namespace std; using namespace std;
int main(int const, const char ** const) int main(int argc, char ** argv)
{ {
// TODO: Handle command line parameters for server's port # unsigned int servPort = 0; /* Initialize Server Port */
if(argc == 2) /* Server Port Specified. Add it */
servPort = atoi(argv[1]);
else
{
cerr << "Usage: " << argv[0] << " <port>\n";
return (1);
}
try try
{ {
...@@ -39,7 +47,7 @@ int main(int const, const char ** const) ...@@ -39,7 +47,7 @@ int main(int const, const char ** const)
myRegistry.addMethod("updateBook", updateBookMethodP); myRegistry.addMethod("updateBook", updateBookMethodP);
myRegistry.addMethod("listBooks", listBooksMethodP); myRegistry.addMethod("listBooks", listBooksMethodP);
xmlrpc_c::serverAbyss myAbyssServer(xmlrpc_c::serverAbyss::constrOpt().registryP(&myRegistry).portNumber(8081)); xmlrpc_c::serverAbyss myAbyssServer(xmlrpc_c::serverAbyss::constrOpt().registryP(&myRegistry).portNumber(servPort));
myAbyssServer.run(); myAbyssServer.run();
// xmlrpc_c::serverAbyss.run() never returns // xmlrpc_c::serverAbyss.run() never returns
......
...@@ -17,7 +17,6 @@ string getISBN() ...@@ -17,7 +17,6 @@ string getISBN()
cout << "Enter the ISBN:"; cout << "Enter the ISBN:";
getline(cin,isbn); getline(cin,isbn);
//cin.getline(isbn,255,'\n');
cout << "\n\n"; cout << "\n\n";
return isbn; return isbn;
...@@ -64,10 +63,9 @@ void result(bool ret) ...@@ -64,10 +63,9 @@ void result(bool ret)
int main(int const, const char ** const) int main(int const, const char ** const)
{ {
// TODO: Handle command line parameters for server's port #
BookDatabase db = BookDatabase(); BookDatabase db = BookDatabase();
Book myBook;// = Book("Title", "Publisher", "1234", 1980, 9.9, 30, "Andrew", "Bob"); Book myBook;
vector<Book> books; vector<Book> books;
string isbn = ""; string isbn = "";
int choice = 0; int choice = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment