Day 3 Mastering the Interface Definition Language (IDL)

2023-10-26

<script LANGUAGE="JavaScript"> </script>


Teach Yourself CORBA In 14 Days

Previous chapterNext chapterContents 


Day 3
Mastering the Interface Definition Language (IDL)

 


Overview

On Day 2 you learned about the details of the CORBA architecture and attained an 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 Interface Definition Language (IDL). IDL is used to describe the interfaces between CORBA objects. You also learned that IDL is neutral with respect to implementation language; in other words, IDL interfaces can be implemented in any language for which a language mapping exists, such as Java, C, C++, and a number of others.

Today you'll explore the various constructs of IDL and learn their uses. You'll start with the primitive data types, such as Booleans, floating point types, integer types, and characters and character strings, which you will find similar to data types found in most programming languages. You'll then move on to constructed types--the enumerated type, the structure type, the union type, and the interface type--which are simply types constructed from other types. Finally, you'll learn about advanced types, such as container types (sequences and arrays), exceptions, and others. By the end of the chapter you'll have covered virtually all there is to know about IDL.

IDL Ground Rules

Before you begin with IDL data types and other constructs, you'll want to cover a 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, and C preprocessor usage.

Case Sensitivity

In IDL, identifiers (such as names of interfaces and operations) are case sensitive. 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 same module 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 and another operation named anOPERATION to be defined simultaneously. Obviously, you haven't yet been exposed to modules, interfaces, and operations; stay tuned to this chapter for more details on these constructs.

 


Note:What the OMG refers to as operations, you might know as methods, member functions, or even messages. 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 operation and method will be used interchangeably, because they refer to exactly the same concept.

IDL Definition Syntax

All definitions in IDL are terminated by a semicolon (;), much as they are in C, C++, and Java. Definitions that enclose other definitions (such as modules and interfaces) do so with braces ({}), again like C, C++, and Java. When a closing brace also appears at the end of a definition, it is also followed by a semicolon. An example of this syntax appears in Listing 3.2 in the section, "The Module."

IDL Comments

Comments in IDL follow the same conventions as Java and C++. Both C-style and C++-style comments are allowed, as illustrated in Listing 3.1. (Note that the second comment in the listing contains embedded comment characters; these are for description purposes only and are not actually allowed by IDL.)

Listing 3.1. IDL comments.
1: // This is a C++-style comment. Anything following the "//"

2: // characters, to the end of the line, is treated as part of the

3: // comment.

4: /* This is a C-style comment. Anything between the beginning

5: "/*" characters and the trailing "*/" characters is treated

6: as part of the comment. */

Use of the C Preprocessor

IDL assumes the existence of a C preprocessor to process constructs such as macro definitions and conditional compilation. If the IDL you write does not make use of these features, you can do without a C preprocessor, but you should recognize that IDL can make use of C preprocessor features.

 


Note: 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.

The Module

The first IDL language construct to examine is the module. The module construct is used to group together IDL definitions that share a common purpose. The use of the module construct is simple: A module declaration specifies the module name and encloses its members in braces, as illustrated in Listing 3.2.

New Term: The grouping together of similar interfaces, constant values, and the like is commonly referred to as partitioning and is a typical step in the system design process (particularly in more complex systems). Partitions are also often referred to as modules (which should be no surprise) or as packages (in fact, the IDL module concept closely resembles the Java package concept--or the other way around, because IDL came first).

Listing 3.2. Module example.
1: module Bank {
  

2: interface Customer {

3: ...

4: };

5: interface Account {

6: ...

7: };

8: ...

9: };

The example in Listing 3.2 defines a module called Bank, which contains two interfaces called Customer and Account (ellipses are used to indicate that the actual definitions are omitted). The examples get ahead of themselves somewhat by using the interface construct here; interfaces are described later in this chapter.

Coupling and Cohesion

New Term: So, now that you have the ability to group interfaces together, how do you decide which interfaces to group together? This is really a question of system design and would be best answered in a text dedicated to that subject. (There are plenty of excellent books available on the subject of object-oriented analysis and design.) However, an overall guideline is that a good design generally exhibits two attributes: loose coupling and tight cohesion. The first means that components in separate modules are not tightly integrated with each other; an application using components in one module generally need not know about components in another module. (Of course, there is often some overlap between modules for various reasons, such as the need to share data between modules or to facilitate common functionality between modules.) When there is little or no dependency between components, they are said to be loosely coupled.

On the other hand, within a single module it is advantageous for a design to achieve tight cohesion. This means that interfaces within the module are tightly integrated with each other. For example, a module called InternalCombustionEngine might contain interfaces such as CylinderHead, TimingChain, Crankshaft, Piston, and many others. It is difficult to describe the purpose of one of these components without referring to the others; hence, one might say that the components are tightly cohesive. By way of comparison, you would probably find very little in common between the components of InternalCombustionEngine and, for instance, AudioSystem; InternalCombustionEngine components such as OilFilter and SparkPlug are loosely coupled to AudioSystem components such as CompactDiscPlayer and Subwoofer.

Figure 3.1 illustrates the concepts of coupling and cohesion; note that there are many relationships between components within the same module, whereas there are few relationships between components within separate modules. The figure also illustrates the advantage of loose coupling between modules: Imagine if, when you installed a new CD player in your car, you had to change the spark plugs and replace your timing chain! Loose coupling of components reduces the possibility that changes to one component will require changes to another.

Figure 3.1. Coupling and cohesion.

Primitive Types

Like most programmin

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Day 3 Mastering the Interface Definition Language (IDL) 的相关文章

  • 在 C# 中将字符串转换为类型[重复]

    这个问题在这里已经有答案了 如果我收到一个包含类名称的字符串 并且我想将该字符串转换为真实类型 字符串中的类型 我该怎么做 I tried Type GetType System Int32 例如 它似乎有效 但是当我尝试使用自己的对象时
  • 在 Objective-C 中呈现另一个类的“控制器”

    如何呈现来自另一个类的 UIAlertController 我想知道如何捕获在 B 类中创建但在 A 类中呈现的 UIAlertController 中的 确定 按钮的操作 这就是我调用在 ClassA 的类 ErrorHandler 上创
  • 处理 Kotlin 协程中自定义 okhttp 拦截器抛出的异常

    我正在使用自定义Interceptor与我的 Android 应用程序中的 Retrofit 客户端一起 在某些特定情况下会引发异常 我正在尝试使用 Kotlin 协程使其工作 问题是我无法处理前面提到的错误 因为在拦截器实例中抛出异常的那
  • DBI:在 eval 中引发错误

    这个问题参考了池上的评论 But if you re going to put an eval around every statement just use RaiseError gt 0 in this thread https sta
  • 不要在异常堆栈中显示 Python raise-line

    当我在 Python 库中引发自己的异常时 异常堆栈将引发行本身显示为堆栈的最后一项 这显然不是一个错误 在概念上是正确的 但是当您在外部使用代码 例如作为模块 时 它会将重点放在对调试无用的东西上 有没有办法避免这种情况并强制 Pytho
  • 如何使用 Jquery 设置输入字段的 Name 属性?

    快速提问 我想知道如何才能实现这一点 好的 我有一个像这样的输入字段
  • Linux 中不使用 C++ 的 C 异常处理

    Linux 是否提供了 C 语言的异常处理而不求助于 C 或者 实现此类异常处理的最佳方法是什么 目标是避免检查每个调用的函数的返回码 而是执行类似于 C 的线程安全且易于移植的操作 您可以通过为其编写信号处理程序来处理信号 GNU 记录的
  • 自定义类上的 List.sum

    我有以下代表 GF2 字段的代码 trait GF2 def unary this def that GF2 GF2 def that GF2 GF2 def that GF2 that match case Zero gt throw n
  • SQL 错误:字符串或二进制数据将被截断

    我正在一个名为 Telligent 的社区平台上进行集成 我正在使用名为 BlogML 的第 3 方插件将博客文章从 XML 文件 BlogML 格式 导入到我的本地 Telligent 站点中 Telligent 平台在其 SDK 中附带
  • CUDD C++ 接口,用于将布尔值转换为 BDD 以及生成的最小项集(到割集)

    我正在与 https github com ivmai cudd https github com ivmai cudd 目标是进行以下重复过程 1 输入 连贯 非递减 布尔函数表达式 顶部 a 1a 2a 3 x 1x 2x 3 z 1z
  • 数据源和数据集的区别

    我目前正在开发一个项目 其主要任务是读取存储在 SQL 数据库中的数据并以用户友好的形式显示它们 使用的编程语言是C 我在 Borland C Builder 6 环境中工作 但我认为标题中提出的问题与编程语言或库无关 当从数据库读取数据时
  • 模板类中的模板函数 is_same

    为什么这段代码会产生错误的输出 this type cpp include
  • 自定义编译器警告

    在 Net 中使用 ObsoleteAtribute 时 它 会向您发出编译器警告 告诉您该对象 方法 属性已过时 应使用其他内容 我目前正在从事一个需要大量重构前员工代码的项目 我想编写一个自定义属性 可用于标记方法或属性 这些方法或属性
  • 捕获 System.Exception 总是不好的做法吗?

    请考虑下面的代码 它抛出三个不同的异常 即 System Configuration ConfigurationErrorsException System FormatException and System OverflowExcept
  • C++ 构造函数抛出异常时销毁对象的成员变量

    这个问题是基于 Scott Meyers 在他的书 更有效的 C 中提供的一个例子 考虑下面的类 A class to represent the profile of a user in a dating site for animal
  • C# 中的异常转换

    为什么我会得到一个InvalidCastException当尝试这样做时 throw ArgumentNullException new Exception errormessage null 这是以下函数的简化版本 public stat
  • UnhandledException 事件不起作用?

    我正在编写一个小库 它捕获所有未处理的异常 显示一个小对话框 类似于 NF 的常见对话框 使用户有机会将异常发送给开发人员 为此 我使用 AppDomain 的 UnhandledException Event 如下所示 app Unhan
  • 运行时动态转换

    有没有一种方法可以在运行时动态转换 如以下伪代码 foreach DataRow row in table Rows foreach DataColumn col in table Columns if row col DBNull Val
  • 当前异常上下文掩盖了先前的错误

    以下是我在 Doug Hellman 网站上名为 masking exceptions catch py 的文件中找到的示例 我暂时无法找到链接 throws 中引发的异常将被丢弃 而 cleanup 中引发的异常将被报告 道格在他的文章中
  • mysql 中 int(11) 列的大小是多少(以字节为单位)?

    柱子的尺寸是多少int 11 在mysql中以字节为单位 该列中可以存储的最大值 An INT无论指定什么长度 都将始终为 4 个字节 TINYINT 1 字节 8 位 SMALLINT 2 字节 16 位 MEDIUMINT 3 字节 2

随机推荐

  • 单词统计

    题目描述 输入一行字符 统计其中有多少个单词 单词之间以空格分隔 输入 一行英文字符 含空格 输出 单词的个数 单独占一行 样例输入 I am a boy 样例输出 4 代码 Java版 import java util Scanner p
  • 毕业后的五年拉开大家差距的原因在哪里?

    有人工作 有人继续上学 大家千万不要错过这篇文章 能看到这篇文章也是一种幸运 真的受益匪浅 对我有很大启迪 这篇文章将会改变我的一生 真的太好了 希望与有缘人分享 也希望对有缘人有所帮助 看完之后有种 相见恨晚 的感觉 特别激动 希望大家好
  • Eclipse环境下通过Cygwin使用NDK编译jni程序

    一 认识Cygwin NDK和jni 首先来认识一下什么是Cygwin NDK和jni Cygwin Cygwin是一个在windows平台上运行的unix模拟环境 它对于学习unix linux操作环境 或者从unix到windows的应
  • java 动态生成 visio----aspose.diagram for java

    最近在鼓捣java 如何生成visio图表 苦于没有API 找到了aspose这个神器 下载试用版本之后 发现最多只能生成10个元素 而且有水印 下面尝试如何去掉水印与元素限制 本文章所涉及的软件均可从网上获取 但是只能用于学习之用 不能用
  • idea使用http客户端上传文件

    controller 文件上传 param file return PostMapping value fileUpload ResponseBody public String uploadSkuImage RequestParam fi
  • 初始C语言——从大到小排序

    三个数的排序 三个数之间两两比较类似于三个数中显示最大值 两两比较 但是有一个问题 最大值问题只需要输出最大值即可而排序问题则还要排序 那么我们是否可以确定三个位置x y z将最大值依次赋值给x y z确保输出时x y z的位置是从左到右输
  • 真二次元!动漫形象风格迁移

    点击上方 机器学习与生成对抗网络 关注星标 获取有趣 好玩的前沿干货 文章 机器之心 一张输入人脸图像 竟能生成多样化风格的动漫形象 伊利诺伊大学香槟分校的研究者做到了 他们提出的全新 GAN 迁移方法实现了 一对多 的生成效果 在 GAN
  • 【JVM】JVM-codecache内存区域介绍

    1 概述 转载 https leokongwq github io 2016 10 12 maven test html 2 JVM codecache内存区域介绍 大家都知道JVM在运行时会将频繁调用方法的字节码编译为本地机器码 这部分代
  • 网络层_数据平面_四(题目完成)

    网络 引入网络层学习 分组交换 虚电路VC 数据报网络 CIDR DHCP 路由器 IP数据报格式 IPv4 IPv6 过渡策略 双栈 隧道 特殊IP地址即内部IP地址 流表中匹配 动作 计算机自顶向下方法 第七版课后习题及答案 正在更新中
  • 论文解读:Investigating the Factual Knowledge Boundary of Large Language Models with Retrieval Augmentati

    论文解读 Investigating the Factual Knowledge Boundary of Large Language Models with Retrieval Augmentation 一 动机 Knowledge in
  • C++ 智能指针我得用用看

    文章目录 0 前言 0 1 使用智能指针的原因 0 2 智能指针和普通指针的区别 什么是智能指针 1 auto ptr 1 1 基本说明 1 2 例子 chestnut 1 3 使用建议 3 unique ptr 3 1 实现原理 3 2
  • [游戏开发]网络同步方式

    状态同步 优点 数据在服务器运算 客户端接收到的数据一定准确 防止数据作弊 角色数据在服务器 客户端只上传操作 想作弊没门 网络波动不敏感 多端表现可以不一致 重视数值准确 缺点 前后端数据包体大 服务器压力比较重 计算量 传输量 研发特点
  • java中冒号(:)的用法

    java中冒号的用法大概可以分为四种 用在for循环中 用来遍历数组 集合 中的元素 for x nums print x 用在三目运算符中 表达式 执行语句1 执行语句2 这里的冒号是用来根据前面表达式的值正确与否 选择后面对应执行语句的
  • 多线程实现的方式

    1 继承Thread类 通过继承Thread类 并重写run方法 public class MyThread extends Thread public static void main String args MyThread myThr
  • sudo vim找不到命令(Ubuntu16.04)

    在使用vim配置环境变量时 提示 sudo vim 找不到命令 原因是因为没有安装vim 下面我们就来在终端进行安装一下 前提是需要连上网了 没有联网不在此考虑范围 1 进入终端 Ctrl Alt T 出现终端窗口 2 输入命令 sudo
  • Linux:WSL 下 CTS 环境搭建及无法识别设备问题

    WSL Windows Subsystem for Linux 简称WSL 是一个在Windows 10上能够运行原生Linux二进制可执行文件 ELF格式 的兼容层 它是由微软与Canonical公司合作开发 其目标是使纯正的Ubuntu
  • mysql [Err] 1118 - Row size too large (> 8126).

    错误代码 1118 Row size too large gt 8126 Changing some columns to TEXT or BLOB may help In current row format BLOB prefix of
  • 获取服务器系统,获取服务器操作系统

    获取服务器操作系统 内容精选 换一换 服务器安装上架 服务器基础参数配置 安装操作系统等操作请参见 Atlas 500 Pro 智能边缘服务器 用户指南 型号 3000 安装操作系统完成后 配置业务网口IP地址 请参见配置网卡IP地址 At
  • arduinows2812灯条程序_Arduino 控制WS2812 LED灯条

    传统的LED限制总是很多 比如需要很多的引脚 所以有一种很好的解决方案是用灯条 理论上这种灯条可以通过通讯 用一根数据总线可以控制达到无上限个数的RGB LED灯珠 并且在数量在1024以下时 延迟是不可察觉的 使用手册可查 主要功能 通过
  • Day 3 Mastering the Interface Definition Language (IDL)

    Teach Yourself CORBA In 14 Days Day 3Mastering the Interface Definition Language IDL Overview IDL Ground Rules Case Sens