helloimpl.cxx

来自「这是经典的CORBA程序」· CXX 代码 · 共 92 行

CXX
92
字号
//-----------------------------------------------------------------------------// Copyright (c) 2003-2020 EBUPT INFO CO.,LTD//-----------------------------------------------------------------------------//// Servant which implements the Hello interface.//#include <omg/orb.hh>#include <stdlib.h>#include <it_cal/iostream.h>#include "HelloImpl.h"IT_USING_NAMESPACE_STD#include "it_print_funcs.h"#include "it_random_funcs.h"// Declare the global ORB defined in the server main file.//extern CORBA::ORB_varglobal_orb;// _create() -- create a new servant.// Hides the difference between direct inheritance and tie servants// For direct inheritance, simple create and return an instance of the servant.// For tie, creates an instance of the tied class and the tie, return the tie.//POA_Hello*HelloImpl::_create(PortableServer::POA_ptr the_poa){    return new HelloImpl(the_poa);}// HelloImpl constructor//// Note: since we use virtual inheritance, we must include an// initialiser for all the virtual base class constructors that// require arguments, even those that we inherit indirectly.//HelloImpl::HelloImpl(    PortableServer::POA_ptr the_poa) :    IT_ServantBaseOverrides(the_poa){    // Intentionally empty.}// ~HelloImpl destructor.//HelloImpl::~HelloImpl(){    // Intentionally empty.    //}// getGreeting() -- Implements IDL operation "Hello::getGreeting".//char*HelloImpl::getGreeting() IT_THROW_DECL((    CORBA::SystemException)){    cout << "HelloImpl::getGreeting(): called." << endl;    char*                           _result;    // Assign values to all the "inout" and "out"    // parameters, and return value, if any.    //    // return value (string)    //    _result = CORBA::string_dup("Hello World!");    // Diagnostics: print the values of "out" and "inout"    // parameters, and the return value, if any.    //    cout << "HelloImpl::getGreeting(): returning..." << endl;    cout << "    _result = ";    global_print->print_string(cout, _result, 1);    cout << endl;    // Return normally.    //    return _result;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?