AuboCaps  0.6.0
program_model.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_PROGRAM_MODEL_H
2 #define AUBO_SCOPE_PROGRAM_MODEL_H
3 
7 
8 namespace arcs {
9 namespace aubo_scope {
10 ARCS_CLASS_FORWARD(ProgramModel);
11 
12 /**
13  * <h1>Summary</h1>
14  * This interface makes it possible to modify sub-trees of AuboCaps.
15  * The structure of trees is separated from the contents of the nodes.
16  * The {@link TreeNode} interface is concerned with the structure of trees
17  * whereas the {@link ProgramNode} interface deals with the concrete content of
18  * the nodes of the tree.
19  *
20  *
21  *
22  * <h1>Getting started with program modification</h1>
23  * A ProgramModel contains a:
24  * <ul>
25  * <li>getProgramNodeFactory() - that makes it possible to create new
26  * program nodes (both built-in AuboScope nodes and AuboCap program nodes).
27  * </li> <li>getRootTreeNode(ProgramNodeContribution root)} - returns the
28  * sub-tree of a given AuboCap ProgramNodeContribution</li>
29  * </ul>
30  *
31  *
32  * The TreeNode interface supports insertion and removal of nodes. With it you
33  * can retrieve the list of children of particular nodes. Calling
34  * lockChildSequence on a tree node, locks the immediate children under the
35  * node. I.e. children can not be rearranged, deleted or have other nodes
36  * inserted into the child sequence by the end user.
37  *
38  * <h1>Example code</h1>
39  * <pre>
40  * public class UpdateProgramExampleContribution implements
41  * ProgramNodeContribution { ProgramModel programModel;
42  *
43  * public UpdateProgramExampleContribution(URCapAPI urCapAPI) {
44  * this.programModel = urCapAPI.getProgramModel();
45  * }
46  *
47  * private void insertIntoProgramTree() {
48  * TreeNode treeNode = programModel.createRootTreeNode(this);
49  * try {
50  * treeNode.addChild(programModel.getProgramNodeFactory().createCommentNode());
51  * } catch (TreeStructureException e) {
52  * // Your handler code
53  * }
54  * }
55  *
56  * //...
57  * //... rest of the implementation and a call to insertIntoProgramTree()
58  * //...
59  * }
60  * </pre>
61  */
63 {
64 public:
67  virtual ~ProgramModel();
68 
69  /**
70  * This method returns a {@link ProgramNodeFactory} to create program nodes.
71  *
72  * @return the factory to create program nodes.
73  */
74  ProgramNodeFactoryPtr getProgramNodeFactory();
75 
76  /**
77  * Gets the {@link TreeNode} root from {@link ProgramNodeContribution}. From
78  * here, children can be added to form a sub-tree.
79  *
80  * @param root The AuboCap program node where a sub-tree is to be rooted.
81  * @return Returns a {@link TreeNode} root.
82  */
83  TreeNodePtr getTreeNode(ProgramNodeContribution *root);
84 
85 private:
86  friend class DataSwitch;
87  ProgramModel();
88  void *d_{ nullptr };
89 };
90 
91 } // namespace aubo_scope
92 } // namespace arcs
93 
94 #endif // AUBO_SCOPE_PROGRAM_MODEL_H
ARCS_CLASS_FORWARD(GripForceCapability)
Defines an API required for specifying a AuboCap Program Node within AuboScope.
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16