📄 client.cxx
字号:
//-----------------------------------------------------------------------------// Copyright (c) 2003-2020 EBUPT INFO CO.,LTD//-----------------------------------------------------------------------------// Automatically generated test client for the following IDL interfaces:// Hello//#include <omg/orb.hh>#include <it_cal/iostream.h>#include <it_cal/fstream.h>#include <stdlib.h>IT_USING_NAMESPACE_STD#include "hello.hh"#include "it_print_funcs.h"#include "it_random_funcs.h"#include "call_funcs.h"// global_orb -- make the ORB global so all code can find it.// CORBA::ORB_var global_orb = CORBA::ORB::_nil();// read_reference() -- read an object reference from file.// Reads a stringified object reference from file and returns a real// object reference.// Caller must release the returned reference or assign it to a _var. // On error returns a nil object reference.//static CORBA::Object_ptrread_reference( const char* file){ cout << "Reading stringified object reference from " << file << endl; ifstream ifs(file); CORBA::String_var str; ifs >> str; if (!ifs) { cerr << "Error reading object reference from " << file << endl; return CORBA::Object::_nil(); } return global_orb->string_to_object(str);}// main() -- the main client program.//intmain(int argc, char **argv){ int exit_status = 0; try { CORBA::Object_var tmp_ref; // For temporary object references. // Initialise the ORB. // Note: ORB_init will process any -ORB arguments // and remove them from argc/argv, so it should // be called before any other argument processing. // global_orb = CORBA::ORB_init(argc, argv); // Initialise the global printer object. // global_print = new IT_GeniePrint(global_orb); // Initialise the global random generator object. // global_random = new IT_GenieRandom(global_orb); // Exercise interface Hello. // tmp_ref = read_reference("Hello.ref"); Hello_var Hello1 = Hello::_narrow(tmp_ref); if (CORBA::is_nil(Hello1)) { cerr << "Could not narrow reference to interface " << "Hello" << endl; } else { CORBA::String_var strV = Hello1->getGreeting(); cout << "Greeting is: " << strV << endl; } } catch(CORBA::Exception &ex) { cerr << "Unexpected CORBA exception: " << ex << endl; exit_status = 1; } // Delete the global print and random objects. // delete global_print; delete global_random; // Ensure that the ORB is properly shutdown and cleaned up. // try { global_orb->shutdown(1); global_orb->destroy(); } catch (...) { // Do nothing. } return exit_status;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -