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