HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_NetworkBoxList.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: OP_NetworkBoxList.h (OP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __OP_NetworkBoxList__
12 #define __OP_NetworkBoxList__
13 
14 #include "OP_API.h"
15 #include <SYS/SYS_Types.h>
16 #include <UT/UT_ValArray.h>
17 #include <iosfwd>
18 
19 #include "OP_Error.h"
20 #include "OP_Node.h"
21 
22 class OP_Network;
23 class OP_NetworkBox;
24 class OP_NetworkBoxItem;
25 class OP_SaveFlags;
26 
27 class OP_API OP_NetworkBoxList : public UT_ValArray<OP_NetworkBox *>
28 {
29 public:
31  // NOTE: We don't need a virtual destructor, because our superclass
32  // has a non-virtual destructor, and this is only destructed
33  // as type OP_NetworkBoxList.
35 
36  /// Remove all network boxes from this list
37  void clearAndDestroy();
38 
39  /// Create a network box with the specified name and insert it into this
40  /// OP_NetworkBoxList at the next available index. Returns a pointer to the
41  /// OP_NetworkBox created or NULL if creation was unsuccessful. Pass in NULL
42  /// as the name if you'd like a default name. If a duplicate name is passed
43  /// in, it will be altered to make it unique. Passing in 'items' will
44  /// automatically create a network box containing those items with the
45  /// netbox positioned properly around them.
46  OP_NetworkBox *createNetworkBox(const char *name,
47  OP_NetworkBoxItemList *items = nullptr);
48 
49  /// Find and return a given network box by name, or NULL if it's not found
50  OP_NetworkBox *findNetworkBox(const char *name) const;
51 
52  /// Find the index of a given network box by name. Returns -1 if not found
53  int findNetworkBoxIndex(const char *name) const;
54 
55  /// Find the index of a given network box by ptr. Returns -1 if not found
56  int findNetworkBoxIndex(OP_NetworkBox *netbox) const;
57 
58  /// Remove a network box by ptr. Returns true if it was successfully
59  /// removed; false if the box wasn't found
60  bool deleteNetworkBox(OP_NetworkBox *netbox);
61 
62  /// Remove a network box by index. Returns true if it was successfully
63  /// removed; false if the index is invalid
64  bool deleteNetworkBox(int index);
65 
66  /// Save the entire list to the ostream os. 'path_prefix' should be the path
67  /// you want to save the netboxes as being under.
68  OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
69  const char *path_prefix) const;
70 
71  ///Load a network box from 'is'. Can load from both .hip files and the
72  ///clipboard. 'path' is used as the new netbox's name (only the portion of
73  ///path after the last slash). If 'overwrite' is specified, the new netbox
74  ///will overwrite any other netboxes in this network with the same name,
75  ///rather than modify its name to be unique. 'created' is used to return a
76  ///ptr to the new network box.
77  bool load(UT_IStream &is, const char *path,
78  bool path_contains_network,
79  bool path_contains_packet_ext,
80  int overwrite = 0, OP_NetworkBox **created = NULL);
81 
82  ///Saves all netboxes in the provided list to the clipboard. Returns the
83  ///total # of items saved.
84  int saveListToClipboard(std::ostream &os,
85  const OP_SaveFlags &flags,
87  &netboxes) const;
88 
89  ///Save 'netbox' to 'os'. 'path_prefix' should be the path you want to save
90  ///the netbox as being under.
91  OP_ERROR saveSingleNetworkBox(std::ostream &os,
92  OP_NetworkBox &netbox,
93  const OP_SaveFlags &flags,
94  const char *path_prefix) const;
95 
96  /// Return the amount of memory owned by this OP_NetworkBoxList
97  int64 getMemoryUsage(bool inclusive) const;
98 
99 private:
100 
101  OP_Network *myNetwork;
102 };
103 
104 #endif
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
int64 getMemoryUsage(bool inclusive=false) const
Definition: UT_Array.h:455
UT_ErrorSeverity
Definition: UT_Error.h:25
GLbitfield flags
Definition: glcorearb.h:1595
long long int64
Definition: SYS_Types.h:106
GLuint const GLchar * name
Definition: glcorearb.h:785
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:785