[sword-cvs] sword/bindings/corba/orbitcpp Makefile,NONE,1.1 server.cpp,NONE,1.1 sword-impl.hpp,NONE,1.1 swordorb-impl.cpp,NONE,1.1 testclient.cpp,NONE,1.1

sword@www.crosswire.org sword@www.crosswire.org
Fri, 2 May 2003 03:36:40 -0700


Update of /usr/local/cvsroot/sword/bindings/corba/orbitcpp
In directory www:/tmp/cvs-serv1210/bindings/corba/orbitcpp

Added Files:
	Makefile server.cpp sword-impl.hpp swordorb-impl.cpp 
	testclient.cpp 
Log Message:
Updated corba service


--- NEW FILE: Makefile ---
all: server testclient

server: server.cpp swordorb-impl.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o
	g++ -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -o server server.cpp swordorb-impl.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o `orbit2-config --libs` -lORBit-2-cpp

testclient: server.cpp swordorb-impl.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-skels.o swordorb-cpp-skels.o
	g++ -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -o testclient testclient.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-skels.o swordorb-cpp-skels.o `orbit2-config --libs` -lORBit-2-cpp

swordorb-common.o: swordorb-common.c
	gcc -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-common.c

swordorb-common.c: ./../swordorb.idl
	orbit-idl-2 -l c ./../swordorb.idl
	orbit-idl-2 -l cpp ./../swordorb.idl

swordorb-cpp-common.o: swordorb-cpp-common.cc
	g++ -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-cpp-common.cc

swordorb-stubs.o: swordorb-stubs.c
	gcc -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-stubs.c

swordorb-cpp-stubs.o: swordorb-cpp-stubs.cc
	g++ -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-cpp-stubs.cc

swordorb-skels.o: swordorb-skels.c
	gcc -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-skels.c

swordorb-cpp-skels.o: swordorb-cpp-skels.cc
	g++ -I. -I../../../include -I/usr/include/orbitcpp-2.0/ `orbit2-config --cflags` -g -c swordorb-cpp-skels.cc

clean:
	rm -f *.h *.cc *.o *.c server testclient


--- NEW FILE: server.cpp ---
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */

#include "sword-impl.hpp"
#include <iostream>

int main (int argc, char* argv[])
{
  try
  {
 	  // Initialize the CORBA orb
 	  CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
	
 	  // Get the root POA
 	  CORBA::Object_var pfobj = orb->resolve_initial_references("RootPOA");

 	  PortableServer::POA_var rootPOA =
         PortableServer::POA::_narrow(pfobj);

 	  // Activate the root POA's manager
 	  PortableServer::POAManager_var mgr = rootPOA->the_POAManager();

 	  mgr->activate();

 	  // Create a Servant and explicitly create a CORBA object
// 	  swordorb::SWModule_impl servant;
// 	  CORBA::Object_var object = servant._this();

 	  // Here we get the IOR for the Hello server object.
 	  // Our "client" will use the IOR to find the object to connect to
// 	  CORBA::String_var ref = orb->object_to_string( object );

 	  // print out the IOR
// 	  std::cout << ref << std::endl;

 	  // run the server event loop
// 	  orb->run();
  }
  catch(const CORBA::Exception& ex)
  {
    std::cout << "Exception caught." << std::endl;
  }

}

--- NEW FILE: sword-impl.hpp ---
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t;c-basic-offset: 4 -*- */
#ifndef _ORBIT_CPP_IDL_sword_IMPL_HH
#define _ORBIT_CPP_IDL_sword_IMPL_HH

#include "swordorb-cpp-skels.h"
#include <swmodule.h>
#include <swkey.h>


namespace swordorb {

//Inherit from abstract Skeleton:
class SWModule_impl : public POA_swordorb::SWModule {
	sword::SWModule *delegate;
public:
	SWModule_impl(sword::SWModule *delegate)  { this->delegate = delegate; }

	void   terminateSearch() throw(CORBA::SystemException) { delegate->terminateSearch = true; }
	char   error() throw(CORBA::SystemException) { return delegate->Error(); }
	CORBA::Long getEntrySize() throw(CORBA::SystemException) { return delegate->getEntrySize(); }
	void   setKeyText(const char *key) throw(CORBA::SystemException) { delegate->KeyText(key); }
	char *getKeyText() throw(CORBA::SystemException) { return (char *)delegate->KeyText(); }
	char *getName() throw(CORBA::SystemException) { return (char *)delegate->Name(); }
	char *getDescription() throw(CORBA::SystemException) { return (char *)delegate->Description(); }
	char *getType() throw(CORBA::SystemException) { return (char *)delegate->Type(); }
	void   previous() throw(CORBA::SystemException) { delegate->decrement(); }
	void   next() throw(CORBA::SystemException) { delegate->increment(); }
	void   begin() throw(CORBA::SystemException) { delegate->setPosition(sword::TOP); }
	char *getStripText() throw(CORBA::SystemException) { return (char *)delegate->StripText(); }
	char *getRenderText() throw(CORBA::SystemException) { return (char *)delegate->RenderText(); }
};

}; // namespace hellomodule


#endif //_ORBIT_CPP_IDL_helloworld_IMPL_HH

--- NEW FILE: swordorb-impl.cpp ---
#include "sword-impl.hpp"
#include <iostream>

/*
char* swordorb::SWModule_impl::helloWorld(const char* greeting) throw(CORBA::SystemException) {
  std::cout << "Server: Greeting was \"" << greeting << "\"" << std::endl;
  return CORBA::string_dup("Hello client, from server!");
}
*/

--- NEW FILE: testclient.cpp ---
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: f; c-basic-offset: 4 -*- */

#include "swordorb-cpp-stubs.h"
#include "swordorb-cpp-common.h"
#include <iostream>
	
int main (int argc, char *argv[])
{
	if (argc != 2)
	{
		std::cerr << "Usage:" << std::endl
				  << "  " << argv[0] << " IOR" << std::endl
				  << std::endl;
		return -1;
	}
	
	try
	{
		// Initialize ORBit
		CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv, "orbit-local-orb");

		// Get a reference to the server from the IOR passed on the
		// command line
		CORBA::Object_var obj = orb->string_to_object(argv[1]);
		swordorb::SWModule_var ptr = swordorb::SWModule::_narrow(obj);

		// The argument is a simple string
		const char* message = "Hello server, from client!";

		// The result is stored in a CORBA-aware smartpointer
		CORBA::String_var reply;

		// Do the actual CORBA call here
		reply = ptr->getName();

		// Print reply
		std::cout << "Client: Reply was \"" << reply << "\"" << std::endl;
		
	} catch(const CORBA::Exception& ex) {
		std::cout << "Exception caught. Maybe the server is not running, or the IOR is wrong." << std::endl;
	}
	
	return 0;
}