HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "OP_DataTypes.h"
16 #include "OP_Error.h"
17 #include "OP_Node.h"
18 #include <UT/UT_ValArray.h>
19 #include <SYS/SYS_Types.h>
20 #include <iosfwd>
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,
81  OP_NetworkBox **created = NULL);
82 
83  ///Saves all netboxes in the provided list to the clipboard. Returns the
84  ///total # of items saved.
85  int saveListToClipboard(std::ostream &os,
86  const OP_SaveFlags &flags,
88  &netboxes) const;
89 
90  ///Save 'netbox' to 'os'. 'path_prefix' should be the path you want to save
91  ///the netbox as being under.
92  OP_ERROR saveSingleNetworkBox(std::ostream &os,
93  OP_NetworkBox &netbox,
94  const OP_SaveFlags &flags,
95  const char *path_prefix) const;
96 
97  /// Return the amount of memory owned by this OP_NetworkBoxList
98  int64 getMemoryUsage(bool inclusive) const;
99 
100 private:
101 
102  OP_Network *myNetwork;
103 };
104 
105 #endif
GLbitfield flags
Definition: glcorearb.h:1596
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
int64 getMemoryUsage(bool inclusive=false) const
Definition: UT_Array.h:657
UT_ErrorSeverity
Definition: UT_Error.h:25
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
OP_OverwriteAction
Definition: OP_DataTypes.h:125
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:786