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 * <p>
13 * This interface provides methods to add and remove script functions in the
14 *Expression Editor accessible from Assignment and If program nodes among
15 *others.
16 * </p>
17 *
18 * <p>
19 * Added functions merely serve as an easy way for the end customer to use the
20 *contributed functions. The implementation of a given script function must be
21 *added in the preamble of program through the use of
22 * {@link InstallationNodeContribution#generateScript(ScriptWriter)}.
23 * </p>
24 *
25 * <p>
26 * The full set of functions which can be contributed must be added in the
27 *preamble at all times, regardless of whether they are added to the Expression
28 *Editor or not. Otherwise old programs that rely on a script function
29 *contribution might stop working.
30 *</p>
31 *
32 * See also {@link Function}.
33 */
35{
36public:
40
41 /**
42 * @param name Name of the function. Safe names must match regex
43 * [a-zA-Z][a-zA-Z0-9_]{0,24} for a total of 25 characters. A range of
44 * Universal Robots reserved names exists and cannot be used. In case of an
45 * illegal or reserved name, an {@link FunctionException} will
46 * be thrown.
47 * @param argumentNames Is a list of hints (for the function arguments) to
48 * be shown comma separated inside angle brackets in the Expression Editor.
49 * No more than five arguments can be specified. The hints must also match
50 * the regex [a-zA-Z][a-zA-Z0-9_]{0,14} for a total of 15 characters.
51 * Otherwise an {@link FunctionException} will be
52 * thrown.
53 * @return If the script function was successfully added, an object
54 * representing the Function will be returned. Null otherwise (e.g. if a
55 * function with the same name was already added).
56 * @throws FunctionException if the name is illegal or more than five
57 * arguments are specified.
58 */
59 FunctionPtr addFunction(const std::string &name,
60 const std::vector<std::string> &argumentNames);
61
62 /**
63 * @param function Function to be removed. Only functions added by this
64 * AuboCap can be removed.
65 * @return <code>true</code>, if the function was successfully removed.
66 * <code>false</code> otherwise (e.g. if the function was not added
67 * by this AuboCap).
68 */
69 bool removeFunction(FunctionPtr func);
70
71 /**
72 * @param name The name of the function.
73 * @return The function if found, otherwise null.
74 */
75 FunctionPtr getFunction(const std::string &name);
76
77 /**
78 * @param filter The filter being applied to the full list of added
79 * functions (by aubo_studio plugins).
80 * @return A collection of added functions that meet the filter criteria.
81 */
82 std::vector<FunctionPtr> getFunctions();
83
84private:
85 friend class DataSwitch;
87 void *d_{ nullptr };
88};
89
90} // namespace aubo_scope
91} // namespace arcs
92
93#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...
FunctionPtr getFunction(const std::string &name)
bool removeFunction(FunctionPtr func)
FunctionModel(FunctionModel &&f)
std::vector< FunctionPtr > getFunctions()
FunctionModel(FunctionModel &f)
FunctionPtr addFunction(const std::string &name, const std::vector< std::string > &argumentNames)