#include #include #include "TreeDecompose_i.h" #include "CipresCommlib/CipresFacilitator.h" #include using namespace std; // // TL - converted from old code below to USING_SIMPLE_SERVER when I needed // to start using a multithreaded poa so that the server can receive // remove() calls while doing other processing. // #define USING_SIMPLE_SERVER #ifdef USING_SIMPLE_SERVER #include "CipresCommlib/CipresSimpleServer.h" using std::string; CipresSimpleServer::NamedServantPtr createServant(const char *); CipresSimpleServer::NamedServantPtr createServant(const char *serviceName) { // serviceName argument is unused return CipresSimpleServer::NamedServantPtr(string("DCM3TreeDecompose"), new CipresIDL_TreeDecompose_i()); } int main (int argc, char **argv) { CipresSimpleServer::ServantFactoryFunc factoryFunc(&createServant); CipresSimpleServer server( "TreeDecompose", // interface name factoryFunc, // factory callback true, // multithreaded poa true); // persistent return server.initializeAndRun(argc, argv); } #else int main(int argc, char **argv) { try { // this calls orb.init FACILITATOR->initialize(argc, argv); CORBA::ORB_ptr orb = FACILITATOR->getORB(); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_object.in()); PortableServer::POAManager_var poa_manager = poa->the_POAManager(); poa_manager->activate(); CipresIDL_TreeDecompose_i td; CipresIDL_api1::TreeDecompose_var tdObject = td._this(); // // this registers with name service/ and or write ior to file // depending on command line arguments. See commlib/CipresFacilitator.cpp // for arguments that are accepted. // // todo: add a cipres arg to dump a usage message. // FACILITATOR->publishIOR(tdObject.in(), "TreeDecompose"); FACILITATOR->run(); } catch(CORBA::Exception &ex) { cerr << "CORBA Exception. " << endl; } catch(int) { cerr << "caught integer exception in main" << endl; } return 0; } #endif