高级软件工程05IIOP、现有产品、开发过程.pptVIP

  • 5
  • 0
  • 约8.43千字
  • 约 39页
  • 2017-12-23 发布于上海
  • 举报

高级软件工程05IIOP、现有产品、开发过程.ppt

高级软件工程05IIOP、现有产品、开发过程

例子 - Grid Object Step-by-Step Define the IDL interface Compile the IDL interface Write a client Implement the interface Write a server mainline Register the server An IDL Interface 编译成 C++: IDL to C++ 映射 ? IDL operations (操作)映射为 C++ 的成员函数 - parameter types 映射为 C++ types ? IDL attributes (属性)映射为 C++的成员函数 - 一个用于获取值 - 另一个用于设置值 (如果不是只读属性) ? IDL data types 映射为 C++ data types ? 一 个 interface 映射为一个 C++ class. 所产生的 C++ code: class Grid : public virtual CORBA::Object { public: static Grid_ptr _bind(....); virtual CORBA::Short height(CORBA::Environment); virtual CORBA::Short width(CORBA::Environment); virtual void set(CORBA::Short row, CORBA::Short col, CORBA::Long value, CORBA::Environment ); virtual CORBA::Long get(CORBA::Short row, CORBA::Short col, CORBA::Environment ); }; Writing a Client #include “grid.hh” #include iostream.h main () { Grid_var p; // Like a C++ pointer // Connect to a remote Grid object p = Grid::_bind(“myGrid:GridSrv”, GridHost); // Now use it like a regular C++ object cout “height is “ p-height() endl; cout “width is “ p-width() endl; p-set(2,4,123); // a remote call cout “grid[2,4] is “ p-get(2,4) endl; }; 如何工作? Implementing the Interface ? 编写一个 C++ class ? 继承 ORB functionality ? 加入数据成员以及其它 C++ 函数 - 根据具体的需求 ? 重定义 IDL 函数 - 提供具体的功能 Grid implementation Grid_i 还包括... IDL 具体功能 什么是 ‘server mainline’? ? server 是 objects的 容 器 - ORB 能激活的可执行代码 ? ‘server mainline’ - 在server中创建初始对象 - 将控制权交给 ORB 以等待调用。 ? 各个对象分别实现自己的功能 - ORB 将接受到的调用分发给具体的对象。 编写 server mainline #include “grid_i.h” #include iostream.h main() { // Create some initial objects // (only one in this case) Grid_i myGrid(100,100); try { //Give control to the ORB CORBA::Orbix.impl_is_ready(); } catch { .... } cout “Server terminating” endl; } Registering the server ? Servers 可以由 ORB 自动启动 - 响应客户请求 ? 注册过程告诉 ORB: - 哪个可执行代码是服务器 - 服务器的激活模式 -

文档评论(0)

1亿VIP精品文档

相关文档