AuboStudio SDK  0.6.3
function_model.h
浏览该文件的文档.
1#ifndef AUBO_SCOPE_FUNCTION_MODEL_H
2#define AUBO_SCOPE_FUNCTION_MODEL_H
3
5
6namespace arcs {
7namespace aubo_scope {
9
10/**
11 * @ingroup InstallationApi
12 * \chinese
13 * 函数模型
14 * 此接口提供在表达式编辑器中添加和删除脚本函数的方法,该编辑器可从赋值和 If
15 * 程序节点等位置访问。
16 *
17 * 添加的函数仅为终端用户提供了一种便捷的方式来使用贡献的函数。特定脚本函数的实现
18 * 必须通过 {@link InstallationNodeContribution#generateScript(ScriptWriter)}
19 * 添加到程序的前导部分。
20 *
21 * 所有可贡献的函数都必须始终添加到前导部分,无论它们是否被添加到表达式编辑器中。
22 * 否则,依赖脚本函数贡献的旧程序可能会停止工作。
23 *
24 * 另请参见 {@link Function}。
25 * \endchinese
26 * \english
27 * FunctionModel
28 * This interface provides methods to add and remove script functions in the
29 * Expression Editor accessible from Assignment and If program nodes among
30 * others.
31 *
32 * Added functions merely serve as an easy way for the end customer to use the
33 * contributed functions. The implementation of a given script function must be
34 * added in the preamble of program through the use of
35 * {@link InstallationNodeContribution#generateScript(ScriptWriter)}.
36 *
37 * The full set of functions which can be contributed must be added in the
38 * preamble at all times, regardless of whether they are added to the Expression
39 * Editor or not. Otherwise old programs that rely on a script function
40 * contribution might stop working.
41 *
42 * See also {@link Function}.
43 * \endenglish
44 */
46{
47public:
51
52 /**
53 * \chinese
54 * 添加脚本函数到表达式编辑器。
55 * @param name 函数名称。有效名称必须匹配正则表达式[a-zA-Z][a-zA-Z0-9_]{0,24},
56 * 共25个字符。部分AUBO Robot保留名称不可使用。
57 * @param argumentNames 函数参数提示列表,在表达式编辑器中以逗号分隔显示在尖括号
58 * 内。最多指定五个参数。
59 * @return 成功添加返回表示函数的对象,否则返回null。
60 * @throws FunctionException 如果名称非法或指定了超过五个参数。
61 * \endchinese
62 * \english
63 * Add a script function to the Expression Editor.
64 * @param name Name of the function. Safe names must match regex
65 * [a-zA-Z][a-zA-Z0-9_]{0,24} for a total of 25 characters.
66 * @param argumentNames Is a list of hints for the function arguments.
67 * @return If the script function was successfully added, an object
68 * representing the Function will be returned. Null otherwise.
69 * @throws FunctionException if the name is illegal or more than five
70 * arguments are specified.
71 * \endenglish
72 */
73 FunctionPtr addFunction(const std::string &name,
74 const std::vector<std::string> &argumentNames);
75
76 /**
77 * \chinese
78 * 移除函数。只能移除此AuboCap添加的函数。
79 * @param function 要移除的函数。
80 * @return 成功移除返回<code>true</code>,否则返回<code>false</code>。
81 * \endchinese
82 * \english
83 * Remove a function. Only functions added by this AuboCap can be removed.
84 * @param function Function to be removed.
85 * @return <code>true</code>, if the function was successfully removed.
86 * \endenglish
87 */
88 bool removeFunction(FunctionPtr func);
89
90 /**
91 * \chinese
92 * 根据名称获取函数
93 * @param name 函数名称。
94 * @return 找到返回函数,否则返回null。
95 * \endchinese
96 * \english
97 * Get a function by name.
98 * @param name The name of the function.
99 * @return The function if found, otherwise null.
100 * \endenglish
101 */
102 FunctionPtr getFunction(const std::string &name);
103
104 /**
105 * \chinese
106 * 获取所有已添加的函数
107 * @return 已添加函数的集合。
108 * \endchinese
109 * \english
110 * Get all added functions.
111 * @return A collection of added functions.
112 * \endenglish
113 */
114 std::vector<FunctionPtr> getFunctions();
115
116private:
117 friend class DataSwitch;
119 void *d_{ nullptr };
120};
121
122} // namespace aubo_scope
123} // namespace arcs
124
125#endif // AUBO_SCOPE_FUNCTION_MODEL_H
#define ARCS_ABI_EXPORT
#define ARCS_CLASS_FORWARD(C)
Macro that forward declares a class and defines the respective smartpointers through ARCS_DECLARE_PTR...
\chinese 函数模型 此接口提供在表达式编辑器中添加和删除脚本函数的方法,该编辑器可从赋值和 If 程序节点等位置访问。
FunctionPtr getFunction(const std::string &name)
\chinese 根据名称获取函数
bool removeFunction(FunctionPtr func)
\chinese 移除函数。只能移除此AuboCap添加的函数。
FunctionModel(FunctionModel &&f)
std::vector< FunctionPtr > getFunctions()
\chinese 获取所有已添加的函数
FunctionModel(FunctionModel &f)
FunctionPtr addFunction(const std::string &name, const std::vector< std::string > &argumentNames)
\chinese 添加脚本函数到表达式编辑器。