NX二次开发UF_CLONE_register_ntfy_callback 函数介绍

51 阅读4分钟

UF_CLONE_register_ntfy_callback

Defined in: uf_clone.h 
int UF_CLONE_register_ntfy_callback(UF_CLONE_notify_cb_t cb, UF_CLONE_notify_callback_t callback, const char * name, const char * description, const char * relative_callback, logical before_relative )

overview 概述

This routine registers a callback function to be called at the notify callback points specified by the cb argument. The name argument is used to identify the callback for later removal, or insertion of other callback functions before or after this function in the callback list. The name should therefore be unique (for this particular callback point). It is recommended that the name should be prefixed with a site specific code. Some callbacks are registered by NX itself, and the names of these all begin with "UGS". Names are considered to be case independent- i.e. "UGS NOTIFY" is the same as "UGS Notify"

If a callback of the same name is already registered at this call back point, then it will be removed before the function supplied is registered.

The Clone operation will call these callbacks in the order in which they are present in the list at the appropriate point in the clone operation. The callback function should generally return UF_CLONE_continue. Calling further callbacks in the list may be prevented by returning UF_CLONE_cut.

Most of the notify callback points have begin and end callbacks: begin (...beg...) callbacks will be called before an operation is about to be performed, allowing a callback to check and forbid it, or perform necessary pre-actions; end callbacks will be called after an operation has completed succesfully, allowing a callback to perform necessary post-actions. Note the end callback corresponding to a begin callback may not be called if the operation in question fails for some reason.

It is possible to specify that the supplied callback should be placed before or after another named callback using the relative_callback and before_relative arguments. If the specified relative callback is not present, the function will return the error UF_CLONE_err_no_relative_cb and place the callback being registered at the beginning or end of the callback list depending on the value of the before_relative flag.


此例程注册一个回调函数,该函数将在 cb 参数指定的通知回调点调用。Name 参数用于标识回调以便以后删除,或者在回调列表中的此函数之前或之后插入其他回调函数。因此,名称应该是唯一的(对于这个特定的回调点)。建议在名称前面加上特定于站点的代码。有些回调函数是由 NX 自己注册的,这些函数的名称都以“ UGS”开头。名称被认为是与大小写无关的——即“ UGS NOTIFY”与“ UGS NOTIFY”相同。如果相同名称的回调已经在这个调用回发点注册,那么它将在所提供的函数注册之前被删除。Clone 操作将按照这些回调在克隆操作的适当位置出现在列表中的顺序调用这些回调。回调函数通常应该返回 UF _ CLONE _ keep。通过返回 UF _ CLONE _ cut 可以防止调用列表中的进一步回调。大多数通知回调点都有开始回调和结束回调: start (... _ beg _...)回调将在操作即将执行之前被调用,允许回调检查并禁止它,或者执行必要的预处理; 结束回调将在操作成功完成之后被调用,允许回调执行必要的后处理。注意,如果有关操作由于某种原因失败,则不能调用开始回调对应的结束回调。可以指定提供的回调应该放在另一个命名的回调之前或之后,这个回调应该使用嘴对嘴和嘴对嘴参数。如果指定的相对回调函数不存在,函数将返回错误 UF _ CLONE _ err _ no _ relevant _ cb,并将正在注册的回调函数放在回调列表的开头或结尾,具体取决于 before _ relative 标志的值。

UFUN例子

获取源码例子请搜索 里海NX二次开发3000例专栏

parameters 参数

UF_CLONE_notify_cb_tcbInputcallback point at which to call function being registered
要调用正在注册的函数的回调点
UF_CLONE_notify_callback_tcallbackInputfunction pointer of the callback function
回调函数的函数指针
const char *nameInputthe name of this callback - should be unique to this callback point
这个回调的名称-应该对这个回调点是唯一的
const char *descriptionInputA description of the callback's function, for information only
回调函数的说明,仅供参考
const char *relative_callbackInputThe name of a callback to position this one relative to, can be NULL, meaning the entire list of callbacks at this point.
用于定位此回调的名称可以为 NULL,这意味着此时整个回调列表。
logicalbefore_relativeInputWhether this callback should be placed before the relative callback (if true) or after it (if false). If the relative callback is NULL or not present, true places the new callback at the beginning of the list, after at the end
这个回调应该放在相对回调之前(如果为真)还是放在相对回调之后(如果为假)。如果相对回调为 NULL 或不存在,则 true 将新回调放置在列表的开头和结尾之后