Posted by: smallonely | December 3, 2003

[CORBA] POA 介面 – (2) the POA mapping II

我們從servant開始說起吧🙂

想法是向一些初始化函數傳遞一個資料結構,這個資料結構持有到物件方法實現函數的
指標的列表。這個資料結構叫做 EPV (entry point vector:入口點向量)。servant
資料結構持有這樣的一個 EPV。

for example,

// idl interface
module FruitsBasket {
interface Apple {
void EatMe ();
void ThrowMe ();
};
};

他 generate 出

typedef struct {
void *_private; /* ORB specific data */
void (*EatMe) (PortableServer_Servant servant, CORBA_Environment * ev);
void (*ThrowMe) (PortableServer_Servant servant, CORBA_Environment * ev);
} POA_FruitsBasket_Apple__epv;

typedef struct {
PortableServer_ServantBase__epv *_base_epv;
POA_FruitsBasket_Apple__epv *FruitsBasket_Apple_epv;
} POA_FruitsBasket_Apple__vepv;

typedef struct {
void *_private; /* ORB specific data */
POA_FruitsBasket_Apple__vepv *vepv;
} POA_FruitsBasket_Apple;

extern void POA_FruitsBasket_Apple__init(POA_FruitsBasket_Apple servant,
CORBA_Environment * ev);
extern void POA_FruitsBasket_Apple__fini(POA_FruitsBasket_Apple servant,
CORBA_Environment * ev);

A servant is thus nothing more than a structure which holds an EPV specific
to the object implementation and a generic EPV called the _base_epv.

這個特定 EPV 是自我說明的:等待填充的function pointers的列表。
The specific EPV is rather self explanatory: function pointers are listed
there, waiting to be filled. The base EPV was not shown there: it is used to
hold some information specific to the servant itself (in fact, a servant may
be responsible for more than one object implementation but it would be
overkill to care about this).

現在,這堿O一個 PortableServer_ServantBase__epv 結構:

typedef struct PortableServer_ServantBase__epv {
void *private; /* ORB specific data */
/* finalization routine called
* to destroy any Servant data
*/
void (*finalize) (PortableServer_Servant, CORBA_Environment *);
/* The POA used by this Servant */
PortableServer_POA (*default_POA) (PortableServer_Servant,
CORBA_Environment *);
} PortableServant_ServantBase__epv;

如果 finalize 和 default_poa 是 NULL, 那把 servlant 傳遞給
POA_FruitsBasket_Apple__init 時,就會用default value,
default_POA is defaulted to the “RootPOA” (就是
CORBA_ORB_resolve_initial_reference (orb, “RootPOA”, &ev) 返回的那個 POA。

Typically, such a set of data structures would be initialized as follows:

void MyEatMe (PortableServer_Servant servant,
CORBA_Environment * ev) {
/* here is your own code which
* corresponds to the object implementation
* 這裡是我自己要implement的code
*/
}
void MyThrowMe (PortableServer_Servant servant,
CORBA_Environment * ev)
{
/* here is your own code which
* corresponds to the object implementation
*/
}

PortableServer_ServantBase__epv base_epv {
NULL, /* ORB specific data */
NULL, /* finalize method */
NULL /* default POA */
}

POA_FruitsBasket_Apple__epv Apple_epv {
NULL, /* ORB specific data */
MyEatMe,
MyThrowMe
};

POA_FruitsBasket_Apple__vepv Apple_vepv {
&base_epv,
&Apple_epv
};

POA_FruitsBasket_Apple Apple_servant = {
NULL, /* ORB specific data */
&Apple_vpev
};


我願陪你流浪 陪你飛翔 陪你尋找你的方向
有你的地方 就是我的家鄉

夫兵者不祥之器物或惡之故有道者不處君子居則貴左用兵則貴右兵者不祥之器非君子
之器不得已BBS telnet://wretch.twbbs.org 開個人板 超快 不用連署得志於天下
矣吉事尚左凶事尚右偏將軍居左上將軍居右言以喪禮處之殺人之眾以哀悲泣之戰勝以
喪禮處之道常無名樸雖小天下莫能臣侯王若能守之萬物將自賓天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦將知止知止可以不殆譬道pcs.csie.nctu.edu.tw海
作者在 03/12/03 16:06:40 從 pcs.csie.nctu.edu.tw 修改這篇文章






—–


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: