HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_MultiparmInfo.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_MultiparmInfo.h ( OP Library, C++)
7  *
8  * COMMENTS:
9  * This class holds information usedto initialize multiparm instances
10  * in OP_Parameters::initMultiparmInstance.
11  */
12 
13 #ifndef __OP_MultiparmInfo_h__
14 #define __OP_MultiparmInfo_h__
15 
16 #include "OP_API.h"
17 #include "OP_Parameters.h"
18 #include <UT/UT_StringArray.h>
19 #include <iosfwd>
20 
22 {
23 public:
26 
27  // Returns the number of multiparm links stored here.
28  int entries() const;
29  // Returns the specified referenced parm.
30  const UT_StringHolder &getReferencedChannel(int index) const;
31  // Returns the specified instance parm.
32  const UT_StringHolder &getInstanceChannel(int index) const;
33 
34  // Associates an instance channel with a referenced channel. If the
35  // instance channel is already referenced, the new value replaces the
36  // old. A null or empty reference clears that reference. A detailed
37  // error message is returned in the error parameter.
38  bool setReference(const char *instancechannel,
39  const char *referencedchannel,
40  UT_String &error);
41 
42  // Performs pattern matching to find the instance channel that best
43  // matches the passed in channel name. The referenced channel is returned
44  // with appropriate replacements already done.
45  bool getReferencedChannel(const char *instancechannel,
46  UT_String &referencedchannel,
47  bool fill_remaining = true) const;
48 
49  // Performs pattern matching to find the instance channel that best
50  // matches the passed in channel name. The referenced channel is returned
51  // with appropriate replacements already done. channel should be the pure
52  // multiparm name, and indices must hold the applicable replacements.
53  //
54  // More specificially, this function checks if the input channel matches one
55  // of the instance channels. The input channel matches a string if it's
56  // equal to the string when some of its #'s are replaced by numbers in the
57  // indices array (indices(0) can only replace the first occurrence of #,
58  // indices(1) can only replace the second, etc.) If such a match is found,
59  // the work buffer will hold the corresponding reference channel, with first
60  // # replaced by the first UNUSED entry in indices, etc.
61  bool getReferencedChannel(const char* channel,
62  const UT_IntArray& indices,
63  UT_WorkBuffer& referenced) const;
64 
65  // Saves the opmultiparm commands required to set up the current
66  // set of references. The "opmultiparm" and node name parts of the
67  // command are not saved, and must be output before calling this
68  // funtion.
69  void saveCommands(std::ostream &os) const;
70 
71  // Saves the multiparm info as into a hip file.
72  void save(std::ostream &os, bool binary) const;
73 
74  // Loads multiparm info as from a hip file.
75  bool load(UT_IStream &is);
76 
77  // Save undo block
78  void saveForUndo();
79 
80  // Tries to match a specific channel name (instancechannel) with a
81  // generic channel name containing "#"s (genericinstancechannel).
82  // The numeric replacements required to match the channel names
83  // are stored in the hashreplacements array.
84  static bool matchChannels(const char *instancechannel,
85  const char *genericinstancechannel,
86  UT_IntArray &hashreplacements);
87 
88  int64 getMemoryUsage(bool inclusive) const
89  {
90  int64 mem = inclusive ? sizeof(*this) : 0;
91  mem += myInstanceChannels.getMemoryUsage(false);
92  mem += myReferencedChannels.getMemoryUsage(false);
93  return mem;
94  }
95 
96  class Undo;
97  friend class Undo;
98 
99 private:
100  OP_Parameters &myOwner;
101  UT_StringArray myInstanceChannels;
102  UT_StringArray myReferencedChannels;
103 };
104 
105 #endif
106 
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
< returns > If no error
Definition: snippets.dox:2
int64 getMemoryUsage(bool inclusive) const
long long int64
Definition: SYS_Types.h:116
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:786