⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch03.htm

📁 corba比较入门级的介绍详细间接了corba访问发布各种细节。
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><SCRIPT LANGUAGE="JavaScript"><!--function popUp(pPage) { var fullURL = document.location; var textURL = fullURL.toString(); var URLlen = textURL.length; var lenMinusPage = textURL.lastIndexOf("/"); lenMinusPage += 1; var fullPath = textURL.substring(0,lenMinusPage); popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394'); figDoc= popUpWin.document; zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>'; zhtm += '</HEAD>'; zhtm += '<BODY bgcolor="#FFFFFF">'; zhtm += '<IMG SRC="' + fullPath + pPage + '">'; zhtm += '<P><B>' + pPage + '</B>'; zhtm += '</BODY></HTML>'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 }//-->                                                                </SCRIPT>	<META NAME="Author" Content="Bryan Flores">	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">	<TITLE>Teach Yourself CORBA In 14 Days -- Ch 3 -- Mastering the Interface Definition Language (IDL)</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><CENTER><H1><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself CORBA In 14 Days</FONT></H1></CENTER><CENTER><P><A HREF="../ch02/ch02.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch04/ch04.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><CENTER><H1><FONT COLOR="#000077">Day 3<BR>Mastering the Interface Definition Language (IDL)</FONT><A HREF="#Heading1"></A></H1></CENTER><UL>	<LI><A HREF="#Heading1">Overview</A>	<LI><A HREF="#Heading2">IDL Ground Rules</A>	<UL>		<LI><A HREF="#Heading3">Case Sensitivity</A>		<LI><A HREF="#Heading4">IDL Definition Syntax</A>		<LI><A HREF="#Heading5">IDL Comments</A>		<LI><A HREF="#Heading6">Use of the C Preprocessor</A>	</UL>	<LI><A HREF="#Heading7">The Module</A>	<UL>		<LI><A HREF="#Heading8">Coupling and Cohesion</A>	</UL>	<LI><A HREF="#Heading9">Primitive Types</A>	<UL>		<LI><A HREF="#Heading10">void</A>		<LI><A HREF="#Heading11">boolean</A>		<LI><A HREF="#Heading12">char and wchar</A>		<LI><A HREF="#Heading13">Floating Point Types</A>		<LI><A HREF="#Heading14">Integer Types</A>		<LI><A HREF="#Heading15">octet</A>		<LI><A HREF="#Heading16">string</A>		<LI><A HREF="#Heading17">The const Modifier</A>	</UL>	<LI><A HREF="#Heading18">Constructed Types</A>	<UL>		<LI><A HREF="#Heading19">The Enumerated Type</A>		<LI><A HREF="#Heading20">The Structure Type</A>		<LI><A HREF="#Heading21">The union Type</A>		<LI><A HREF="#Heading22">The interface Type</A>	</UL>	<LI><A HREF="#Heading23">Other IDL Constructs</A>	<UL>		<LI><A HREF="#Heading24">typedef</A>		<LI><A HREF="#Heading25">Forward Declarations</A>	</UL>	<LI><A HREF="#Heading26">Container Types</A>	<UL>		<LI><A HREF="#Heading27">The sequence Type</A>		<LI><A HREF="#Heading28">The Array</A>	</UL>	<LI><A HREF="#Heading29">The exception Type</A>	<UL>		<LI><A HREF="#Heading30">exception</A>		<LI><A HREF="#Heading31">Standard Exceptions</A>	</UL>	<LI><A HREF="#Heading32">The any Type</A>	<LI><A HREF="#Heading33">The TypeCode Pseudotype</A>	<LI><A HREF="#Heading34">Summary</A>	<LI><A HREF="#Heading35">Q&amp;A</A>	<LI><A HREF="#Heading36">Workshop</A>	<UL>		<LI><A HREF="#Heading37">Quiz</A>		<LI><A HREF="#Heading38">Exercises</A>	</UL></UL><P><HR SIZE="4"><CENTER><H1><FONT COLOR="#000077"></FONT></H1></CENTER><H2><A NAME="Heading1"></A><FONT COLOR="#000077">Overview</FONT></H2><P>On Day 2 you learned about the details of the CORBA architecture and attainedan understanding of the various CORBA application components and their purposes.One chief component of the CORBA architecture, as you saw, is the use of the InterfaceDefinition Language (IDL). IDL is used to describe the interfaces between CORBA objects.You also learned that IDL is neutral with respect to implementation language; inother words, IDL interfaces can be implemented in any language for which a languagemapping exists, such as Java, C, C++, and a number of others.</P><P>Today you'll explore the various constructs of IDL and learn their uses. You'llstart with the primitive data types, such as Booleans, floating point types, integertypes, and characters and character strings, which you will find similar to datatypes found in most programming languages. You'll then move on to constructed types--theenumerated type, the structure type, the union type, and the interface type--whichare simply types constructed from other types. Finally, you'll learn about advancedtypes, such as container types (sequences and arrays), exceptions, and others. Bythe end of the chapter you'll have covered virtually all there is to know about IDL.<H2><A NAME="Heading2"></A><FONT COLOR="#000077">IDL Ground Rules</FONT></H2><P>Before you begin with IDL data types and other constructs, you'll want to covera few ground rules of IDL syntax and other aspects of the IDL language. In particular,IDL has rules regarding case sensitivity, definition syntax, comment syntax, andC preprocessor usage.<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Case Sensitivity</FONT></H3><P>In IDL, identifiers (such as names of interfaces and operations) are case sensitive<I>.</I>In other words, an interface called myObject cannot be referred to later as myOBJECT.Besides these identifiers being case sensitive, IDL imposes another restriction:The names of identifiers in the same scope (for instance, two interfaces in the samemodule or two operations in the same interface) cannot differ in case only. For example,in the myObject interface, IDL would not allow an operation named anOperation andanother operation named anOPERATION to be defined simultaneously. Obviously, youhaven't yet been exposed to modules, interfaces, and operations; stay tuned to thischapter for more details on these constructs.<BLOCKQUOTE>	<P><HR><B>Note:</B>What the OMG refers to as <I>operations,</I> you might know as <I>methods</I>,	<I>member functions</I>, or even <I>messages</I>. Whatever name you know it by, an	operation defines a particular behavior of an interface, including the input and	output parameters of that particular behavior. Throughout this book, the terms <I>operation</I>	and <I>method</I> will be used interchangeably, because they refer to exactly the	same concept. <HR></BLOCKQUOTE><H3><A NAME="Heading4"></A><FONT COLOR="#000077">IDL Definition Syntax</FONT></H3><P>All definitions in IDL are terminated by a semicolon (;), much as they are inC, C++, and Java. Definitions that enclose other definitions (such as modules andinterfaces) do so with braces ({}), again like C, C++, and Java. When a closing bracealso appears at the end of a definition, it is also followed by a semicolon. An exampleof this syntax appears in Listing 3.2 in the section, &quot;The Module.&quot;<H3><A NAME="Heading5"></A><FONT COLOR="#000077">IDL Comments</FONT></H3><P>Comments in IDL follow the same conventions as Java and C++. Both C-style andC++-style comments are allowed, as illustrated in Listing 3.1. (Note that the secondcomment in the listing contains embedded comment characters; these are for descriptionpurposes only and are not actually allowed by IDL.)<H4><FONT COLOR="#000077">Listing 3.1. IDL comments.</FONT></H4><PRE><FONT COLOR="#0066FF">1: // This is a C++-style comment. Anything following the &quot;//&quot;2: // characters, to the end of the line, is treated as part of the3: // comment.4: /* This is a C-style comment. Anything between the beginning5:    &quot;/*&quot; characters and the trailing &quot;*/&quot; characters is treated6: as part of the comment. */</FONT></PRE><H3><A NAME="Heading6"></A><FONT COLOR="#000077">Use of the C Preprocessor</FONT></H3><P>IDL assumes the existence of a C preprocessor to process constructs such as macrodefinitions and conditional compilation. If the IDL you write does not make use ofthese features, you can do without a C preprocessor, but you should recognize thatIDL can make use of C preprocessor features.<BLOCKQUOTE>	<P><HR><B>Note:</B> The C preprocessor, included with C and C++ compilers and with some	operating systems, is a tool that is essential to the use of those languages. (The	Java language does not use a preprocessor.) Before a C or C++ compiler compiles code,	it runs the preprocessor on that code. The preprocessor, among other things, resolves	macros, processes directives such as #ifdef...#endif and #include, and performs substitutions	of #defined symbols. For more information on the C preprocessor, consult a C or C++	text, or if you have access to a UNIX system, try man cpp. <HR></BLOCKQUOTE><H2><A NAME="Heading7"></A><FONT COLOR="#000077">The Module</FONT></H2><P>The first IDL language construct to examine is the module<I>.</I> The module constructis used to group together IDL definitions that share a common purpose. The use ofthe module construct is simple: A module declaration specifies the module name andencloses its members in braces, as illustrated in Listing 3.2.</P><P><B>New Term: </B>The grouping together of similar interfaces, constant values,and the like is commonly referred to as <I>partitioning</I> and is a typical stepin the system design process (particularly in more complex systems). Partitions arealso often referred to as modules (which should be no surprise) or as packages (infact, the IDL module concept closely resembles the Java package concept--or the otherway around, because IDL came first).<H4><FONT COLOR="#000077">Listing 3.2. Module example.</FONT></H4><PRE><FONT COLOR="#0066FF">1: module Bank {2:     interface Customer {3:         ...4:     };5:     interface Account {6:         ...7:     };8:     ...9: }; </FONT></PRE><P>The example in Listing 3.2 defines a module called Bank, which contains two interfacescalled Customer and Account (ellipses are used to indicate that the actual definitions

⌨️ 快捷键说明

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