几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 07:40 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】oddbentityclose90

oddbentity::close()
oddbentity::close()
hi. i am a japanese. i am sorry in poor english.
the result that an object was opened is received by the program which used odt3.x with a smart pointer.
it was considerate here.
the means which closes the object that it opened specifically doesn't exist.
is it good if the part doing pentity->close() how is written again?
when is an object actually closed?
is an object closed automatically when the reference count of the object becomes a zero?
but, it is supposed to be sometimes troublesome with that.
because, pentity->cancel() isn't made.

the object is closed when its reference counter becomes 1. one reference is from database internals. so if reference counter is 1 - nothing points to it except database. you need not call close() function.
transaction resident objects (which were opened after starttransaction() was called) will be closed at outermost transaction end. transaction references opened objects.
where is no oddbobject::cancel() function. aborttransaction() should be used to roll back modifications made after starttransaction() call.
if you need to roll back changes made after objects were closed and notifications invoked you can use undo functionality.
btw, in posted toolkit version aborttransaction() and undo do not work but they are very close to be finished.
sergey slezkin

hi.
i also have same question about oddbobject::close()/cancel().
i know that using transaction is recommended scheme, and the fact, i usually take it, if possible.
although, in the real, a lot of arx'es don't use transaction. and in addition, unless if i mis-understand, current arx cannot use any transactions if target database is not assosiated with a document.
on the one hand, it's seemed to be very important strategy that how to take attantions from many arx developers in the world, and how to re-use existing arx sources for odt v3 deployment.
all arx developers are strongly aducated like 'all things you opened must be closed, or else, unexpected result will happen.'
in ideal, you are quitely right.
but in the real, i think, not always the best way it is.
and at the last, when i make dummy oddbobject::close() method, how is the most near implementation?
for example, after open it, only decrementing the reference count by one is the most near implementation for 'close()'?
thank you.
---
arx developer,
hyogo japan.

using smart pointers you need not call close() explicitly. the object will be closed in smart pointer destructor or if you assign a new value (maybe 0) to the smart pointer.
object is not closed untill the last smart pointer pointing to it is destroyed or assigned another value.
if your goal is to compile and run a code written for autocad's objectarx without its editing, implementing oddbobject::close() method will not be sufficient. probably writing some set of wrapper functions will be required.
objectarx open function returns acdbobject* pointer.
oddbobjectid: penobject() returns smart pointer so code below will not work.
oddbobject *pobj = id.openobject();
pobj->dosomething()// error. object is closed
// because it's not referenced
// by smart pointer any more
correct code:
{
oddbobjectptr pobj = id.openobject();
pobj->dosomething();
} // here object is closed in smart pointer destructor
or:
{
oddbobjectptr pobj = id.openobject();
pobj->dosomething();
pobj = 0; // object is closed
...
}
note that no invalid smart pointer can exist.
to emulate arx like behaviour open function returning "normal", not smart pointer is required. it should "addref" the object. close function in such case should call "release" method.
but using smart pointers and close() implemented via release() - decrementing reference counter is not safe - if you decrement reference counter manually in your close() implementation you need to increment it manually in your open() implementation.
sergey slezkin

thank you for detailed explanation.
i found great hint from your explanation:
> or:
>
> {
> oddbobjectptr pobj = id.openobject();
> pobj->dosomething();
> pobj = 0; // object is closed
> ...
> }
by this way, it can be possible to provide alternate acdbobject::close() method.
thank you very much.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 06:27 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多