12.07.2015 Views

VisiBroker Edition

VisiBroker Edition

VisiBroker Edition

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

在 IDL 中 定 义 接 口 属 性由 IDL 编 译 器 生 成 的 类 模 板仅 适 用 于 C++:除 了 生 成 POA_example 类 之 外 , IDL 编 译 器 还 生 成 了 一 个 命 名 为 _tie_example 的类 模 板 。 如 果 您 不 愿 意 从 POA_example 派 生 一 个 类 , 则 可 以 使 用 此 模 板 。 模 板 很 有用 , 它 们 可 以 为 不 能 通 过 修 改 来 继 承 一 个 新 类 的 现 有 应 用 提 供 wrapper ( 封 装 )类 。 以 下 的 代 码 示 例 示 范 由 IDL 编 译 器 为 example 类 生 成 的 模 板 类 。:template class POA_example_tie :public POA_example {public:POA_example_tie (T& t):_ptr(&t), _poa(NULL), _rel((CORBA::Boolean)0) {}POA_example_tie (T& t, PortableServer::POA_ptr poa):_ptr(&t),_poa(PortableServer::_duplicate(poa)), _rel((CORBA::Boolean)0) {}POA_example_tie (T *p, CORBA::Boolean release= 1): _ptr(p),_poa(NULL), _rel(release) {}POA_example_tie (T *p, PortableServer::POA_ptr poa, CORBA::Boolean release =1): _ptr(p), _poa(PortableServer::_duplicate(poa)), _rel(release) {}virtual ~POA_example_tie() { /* . . . */ }T* _tied_object() { /* . . . */ }void _tied_object(T& t) { /* . . . */ }void _tied_object(T *p, CORBA::Boolean release=1) { /* . . . */ }CORBA::Boolean _is_owner() { /* . . . */ }void _is_owner(CORBA::Boolean b) { /* . . . */ }CORBA::Long op1(CORBA::Char _x, CORBA::Short_out _y) { /* . . . */ }PortableServer::POA_ptr _default_POA() { /* . . . */ }};有 关 使 用 _tie 模 板 类 的 详 情 , 请 参 阅 “ 使 用 tie 机 制 。”您 也 可 以 生 成 一 个 _ptie 模 板 , 以 便 将 对 象 库 集 成 在 您 的 服 务 器 上 。在 IDL 中 定 义 接 口 属 性除 了 定 义 操 作 之 外 , 接 口 规 范 也 可 以 定 义 属 性 作 为 接 口 的 一 部 分 。 在 默 认 情 况 下 ,所 有 的 属 性 都 是 读 写 型 , IDL 编 译 器 将 生 成 两 种 方 法 : 其 中 一 是 设 定 属 性 的 值 ,另 外 一 个 是 取 得 属 性 的 值 。 您 也 可 以 指 定 只 读 属 性 , 仅 为 此 类 属 性 生 成 reader方 法 。以 下 的 IDL 示 例 说 明 定 义 两 种 属 性 的 IDL 规 范 : 一 种 是 读 写 , 一 种 是 只 读 。interface Test {attribute long count;readonly attribute string name;};以 下 的 代 码 示 例 说 明 为 IDL 中 声 明 的 接 口 所 生 成 的 操 作 类 。C++: class test :public virtual CORBA::Object {...// 读 写 属 性 的 方 法virtual CORBA::Long count();virtual void count(CORBA::Long __count);使 用 IDL 11-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!