1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/CONCEPT/client.h>
#include <BALL/VIEW/KERNEL/common.h>
using namespace std;
using namespace BALL;
int main(int argc, char** argv)
{
// check for command line arguments
if (argc != 3)
{
cerr << argv[0] << " <host>[:<port>] <PDB file>" << endl;
cerr << " Reads a PDB file and sends its contents via the network" << endl;
cerr << " to the BALLVIEW server listening on <port> of <host> and" << endl;
cerr << " displays the contents of the file there." << endl;
cerr << " If no port is given, the default port 20000 is assumed." << endl << endl;
return 1;
}
// open a file for input
PDBFile pdb_file(argv[2]);
if (pdb_file.bad())
{
cerr << "Cannot open PDB file " << argv[2] << endl;
return 2;
}
// create a system and read the contents of the
// PDB file into this system
System S;
pdb_file >> S;
pdb_file.close();
// extract the hostname and port from the command line
String host_port(argv[1]);
String host;
Size port;
if (host_port.has(':'))
{
port = String(host_port.after(":")).toUnsignedInt();
host = host_port.before(":");
}
else
{
host = host_port;
port = VIEW_DEFAULT_PORT;
}
// create a BALLVIEW client and
// connect to the given host and port
cout << "connecting to port " << port << " of " << host << endl;
Client client(host, port);
// transmit the system
cout << "sending " << S.countAtoms() << " atoms to " << host << endl;
client.insert(S);
// that's it.
cout << "done." << endl;
return 0;
}
|