Orbix 3.3.13 Programmer's Guide C++ Edition
Total Page:16
File Type:pdf, Size:1020Kb
Orbix 3.3.13 Programmer’s Guide C++ Edition Micro Focus The Lawn 22-30 Old Bath Road Newbury, Berkshire RG14 1QN UK http://www.microfocus.com Copyright © Micro Focus 2015. All rights reserved. MICRO FOCUS, the Micro Focus logo and Micro Focus Licensing are trademarks or registered trademarks of Micro Focus IP Development Limited or its subsidiaries or affiliated companies in the United States, United Kingdom and other countries. All other marks are the property of their respective owners. 2015-09-10 ii Contents Preface................................................................................ vii Audience ............................................................................................... vii Organization of this Guide ....................................................................... vii Document Conventions .......................................................................... viii Part I Getting Started Introduction to CORBA and Orbix ..........................................3 CORBA and Distributed Object Programming ................................................3 The Object Management Architecture ..........................................................7 How Orbix Implements CORBA ...................................................................9 Orbix Components .................................................................................10 Orbix Architecture ..................................................................................10 Developing Applications with Orbix.....................................15 Developing a Distributed Application .........................................................15 Defining IDL Interfaces ...........................................................................15 Compiling IDL Interfaces .........................................................................17 Implementing the IDL Interfaces ..............................................................19 Writing an Orbix Server Application ..........................................................21 Writing an Orbix Client Application ...........................................................25 Compiling the Client and Server ...............................................................28 Running the Application ..........................................................................29 Summary of Programming Steps ..............................................................30 Part II Orbix C++ Programming Introduction to CORBA IDL..................................................33 IDL Modules and Scoping ........................................................................33 Defining IDL Interfaces ...........................................................................34 Overview of the IDL Data Types ...............................................................39 The CORBA IDL to C++ Mapping..........................................47 Overview of the Mapping .........................................................................47 Mapping for Modules and Scoping .............................................................48 Mapping for Interfaces ............................................................................49 Mapping for IDL Data Types ....................................................................57 Mapping for Pseudo-Object Types .............................................................75 Memory Management and _var Types .......................................................75 Memory Management for Parameters ........................................................78 Using and Implementing IDL Interfaces..............................87 Overview of an Example Application .........................................................87 Overview of the Programming Steps .........................................................88 Defining IDL Interfaces ...........................................................................88 Orbix Programmer’s Guide C++ Edition iii Implementing IDL Interfaces ...................................................................89 Developing a Server Program ...................................................................99 Developing a Client Program ..................................................................102 Registering the Server ..........................................................................105 Execution Trace for the Example Application ............................................105 Comparing the TIE and BOAImpl Approaches ...........................................109 Making Objects Available in Orbix..................................... 113 Identifying CORBA Objects ....................................................................113 Using the CORBA Naming Service ...........................................................116 Transferring Object References ..............................................................120 Binding to Orbix Objects ........................................................................122 Exception Handling in Orbix.............................................. 125 An Example of Raising and Handling Exceptions ........................................125 Using Inheritance of IDL Interfaces.................................. 133 The IDL Interfaces ................................................................................133 Implementation Class Hierarchies ...........................................................134 The Implementation Classes ..................................................................135 Using Inheritance in a Client ..................................................................138 Multiple Inheritance of IDL Interfaces ......................................................139 Orbix Connections and Events .......................................... 141 Overview of the Direct API to Orbix .........................................................141 Managing Orbix Connections and Events ..................................................143 Advanced Programming Topics......................................... 151 Developing Collocated Clients and Servers ...............................................151 Determining Locality of Objects ..............................................................153 Determining Hierarchy of Objects ...........................................................154 Casting from Interface to Implementation Class .......................................155 Actions when Proxy Code is Unavailable ..................................................156 Multiple Implementations of an Interface .................................................157 Multiple Interfaces per Implementation ...................................................158 Passing Context Information to IDL Operations .........................................161 Receiving Diagnostic Messages from Orbix ...............................................163 Part III Dynamic Orbix C++ Programming The TypeCode Data Type................................................... 167 Overview of the TypeCode Data Type ......................................................167 Implementation of TypeCode in Orbix .....................................................169 Examples of Using TypeCode .................................................................170 The Any Data Type............................................................ 173 Inserting Data into an Any with operator<<=() ........................................173 Interpreting an any with operator>>=() ..................................................175 Other Ways to Construct and Interpret an Any .........................................177 Any Constructors, Destructor and Assignment ..........................................182 Any as a Parameter or Return Value .......................................................183 iv Orbix Programmer’s Guide C++ Edition Dynamic Invocation Interface ...........................................185 Using the DII ....................................................................................... 185 The CORBA Approach to Using the DII .................................................... 187 The Orbix-Specific Approach to Using the DII ........................................... 194 Dynamic Skeleton Interface ..............................................201 Uses of the DSI ................................................................................... 201 Using the DSI ...................................................................................... 202 Example of Using the DSI ..................................................................... 205 The Interface Repository...................................................209 Configuring the Interface Repository ....................................................... 209 Runtime Information about IDL Definitions .............................................. 209 The Structure of Interface Repository Data .............................................. 210 Abstract Interfaces in the Interface Repository ......................................... 213 Containment in the Interface Repository ................................................. 215 Type Interfaces in the Interface Repository ............................................. 222 Retrieving Information about IDL Definitions ............................................ 225 Example of Using the Interface Repository .............................................. 227 Repository IDs ....................................................................................