Rumba C++ SDK
Node.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Impl.h"
18 #include "Plug.h"
19 #include "StringView.h"
20 
21  namespace maquina
22  {
24 
37  {
38  public:
40 
41  Node(const char* type,
42  const char* name,
43  Node* parent = nullptr,
44  bool undo_stack=false
45  );
46 
49  Node* parent = nullptr,
50  bool undo_stack = false
51  ) const;
52 
54  void delete_node(
55  bool undo_stack=false
56  );
57 
58  void rename(const char* new_name, bool undo_stack = false);
59 
61  const char* name() const;
62 
64  std::string full_name() const;
65 
67  std::string full_document_name() const;
68 
70  const char* ui_descriptor() const;
71 
73  const char* type_name() const;
74 
76  StringView ui_description() const;
77 
79  bool is_instance( const char* node_type_name ) const;
80 
82 
83  bool is_referenced() const;
84 
86 
87  bool is_mutable() const;
88 
90 
91  bool is_reference_root() const;
92 
94  bool is_reference_loaded() const;
95 
97  bool is_serializable() const;
98 
100 
101  bool is_document_node() const;
102 
105  void set_serializable( bool serialize );
106 
108 
109  std::wstring reference_filename() const;
110 
112 
114  void unload_reference();
115 
117 
120  void load_reference();
121 
123 
125  void replace_reference(const std::wstring& new_reference);
126 
128 
129  void write(const std::wstring& filename) const;
130 
132 
134  {
135  public:
138  public std::iterator<
139  std::forward_iterator_tag,
140  Node, std::ptrdiff_t, Node, Node >
141  {
142  public:
143  reference operator*() const;
144  bool operator==(const Iterator &other) const;
145  bool operator!=(const Iterator &other) const;
146  Iterator& operator++();
147  Iterator(void *iterator);
148  Iterator( const Iterator &other );
149  ~Iterator();
150  private:
151  void *_internal;
152  };
153 
154  Children( void *node )
155  : _node{ node }
156  {}
157  Iterator begin() const;
158  Iterator end() const;
159 
161  size_t size() const;
162  private:
163  void* _node;
164  };
165 
167  Children children() const;
168 
170  bool has_parent() const;
171 
173 
174  Node parent() const;
175 
177 
178  void set_parent(Node& parent, bool undo_stack);
179 
181  bool has_document() const;
182 
184 
185  Node document() const;
186 
188  bool has_child(const char* child_name) const;
189 
191 
192  Node child(const char* name) const;
193 
195  bool is_child_of(const Node& parent) const;
196 
198 
199  Node find_first(const char* name) const;
200 
202 
204  {
205  public:
208  public std::iterator<
209  std::forward_iterator_tag,
210  Plug, std::ptrdiff_t, Plug, Plug >
211  {
212  public:
213  reference operator*() const;
214  bool operator==(const Iterator &other) const;
215  bool operator!=(const Iterator &other) const;
216  Iterator& operator++();
217  Iterator( const std::shared_ptr< Impl > &node, void *iterator );
218  Iterator( const Iterator &other );
219  ~Iterator();
220  private:
221  std::shared_ptr< Impl > _node;
222  void *_internal;
223  };
224 
225  Plugs( void *node )
226  : _node{ node }
227  {}
228  Iterator begin();
229  Iterator end();
230  private:
231  void* _node;
232  };
233 
235  Plugs plugs() const;
236 
238  bool has_plug(const char* plug_name) const;
239 
241 
248  Plug add_plug( const char* name, const Value& default_value, int flags = Flags::serial, bool undo_stack = false, const std::string & description = "" );
249 
258  void remove_plug( const char* name, bool undo_stack = false );
259 
268  void remove_plug( const Plug& plug, bool undo_stack = false );
269 
271 
283  Plug plug(const char* plug_name) const;
284 
286  std::vector<Plug> channels() const;
287 
289 
291  std::vector<Node> relationship();
292 
294  const std::vector<std::string>& bases() const;
295 
297  Node random_child();
298 
300  std::shared_ptr<NodePlugin> plugin() const;
301 
303 
304  std::vector<Node> search(
305  const std::string& key
306  ) const;
307 
308  std::shared_ptr<class NodeDelegate> node_delegate();
309 
311 
314  void notify_first_init(bool undo_stack);
315 
316  bool operator==(const Node& o) const { return _impl == o._impl; }
317  bool operator!=(const Node& o) const { return _impl != o._impl; }
318 
320  std::shared_ptr<Impl> _impl;
321 
323  Node(const std::shared_ptr<Impl>& impl)
324  : _impl{ impl }
325  {}
326  };
327 
329  // This is can't be done in Plug:: because of a cyclic class definition issue
330  MAQUINA_EXPORT Node plug_node(const Plug& plug);
331  }
bool operator==(const Node &o) const
Definition: Node.h:316
MAQUINA_EXPORT Node reference(Node &root, const std::wstring &filepath, const std::string &reference_root_name="")
Reference the content of a file into the project.
Buffer< T > duplicate(const BufferConst< T > &a)
Definition: Buffer.h:161
bool operator!=(const Node &o) const
Definition: Node.h:317
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
A Plug accessor.
Definition: Node.h:203
Plugs(void *node)
Definition: Node.h:225
#define MAQUINA_EXPORT
Definition: Export.h:31
A node plug.
Definition: Plug.h:52
A Node children iterator.
Definition: Node.h:137
MAQUINA_EXPORT Node plug_node(const Plug &plug)
Get a plug node.
bool operator!=(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:305
Flags
Definition: Plug.h:55
bool operator==(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:273
A Plug iterator.
Definition: Node.h:207
Color4< T > operator*(S a, const Color4< T > &v)
Definition: ImathColor.h:727
A Node children accessor.
Definition: Node.h:133
Children(void *node)
Definition: Node.h:154
Base class of all Rumba nodes.
Definition: Node.h:36
Base class of all Rumba values.
Definition: Value.h:34