POA_exampleクラスに加えて,IDLコンパイラは_tie_exampleという名前のクラステンプレートを生成します。このテンプレートは,クラスをPOA_exampleから派生させたくない場合に使用します。テンプレートは,新しいクラスを継承するために変更できない既存のアプリケーションのオブジェクトラッパークラスを提供する場合に役立ちます。コードサンプル11-12に,exampleクラス用にIDLコンパイラが生成したテンプレートクラスを示します。
template <class T>
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テンプレートクラスの使用については,「9. tie機能の使用」を参照してください。
オブジェクトデータベースとユーザのサーバを統合するために,_ptieテンプレートを生成することもできます。