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)
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:
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;
*/
};
#endif /* BOOK_H_ */
......@@ -6,6 +6,7 @@
#include <cstdlib>
#include <assert.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <xmlrpc-c/girerr.hpp>
......@@ -67,20 +68,29 @@ void printResult(bool ret)
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;
exit(1);
case 3:
hostname = argv[2];
case 2:
servPort = argv[1];
break;
default:
cerr << "Usage: " << argv[0] << " <port> [hostname]\n";
return (1);
}
try
{
string URL = "http://" + hostname + ":" + servPort + "/RPC2";
BookHandler bookHandle;
string const serverUrl("http://localhost:8081/RPC2");
string const serverUrl(URL);
string const addBook("addBook");
string const deleteBook("deleteBook");
string const searchBook("searchBook");
......
......@@ -9,6 +9,7 @@
#include <stdexcept>
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <string>
#include <xmlrpc-c/base.hpp>
......@@ -19,9 +20,16 @@
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
{
......@@ -39,7 +47,7 @@ int main(int const, const char ** const)
myRegistry.addMethod("updateBook", updateBookMethodP);
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();
// xmlrpc_c::serverAbyss.run() never returns
......
......@@ -17,7 +17,6 @@ string getISBN()
cout << "Enter the ISBN:";
getline(cin,isbn);
//cin.getline(isbn,255,'\n');
cout << "\n\n";
return isbn;
......@@ -64,10 +63,9 @@ void result(bool ret)
int main(int const, const char ** const)
{
// TODO: Handle command line parameters for server's port #
BookDatabase db = BookDatabase();
Book myBook;// = Book("Title", "Publisher", "1234", 1980, 9.9, 30, "Andrew", "Bob");
Book myBook;
vector<Book> books;
string isbn = "";
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