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) const;
47 
48  // Performs pattern matching to find the instance channel that best
49  // matches the passed in channel name. The referenced channel is returned
50  // with appropriate replacements already done. channel should be the pure
51  // multiparm name, and indices must hold the applicable replacements.
52  //
53  // More specificially, this function checks if the input channel matches one
54  // of the instance channels. The input channel matches a string if it's
55  // equal to the string when some of its #'s are replaced by numbers in the
56  // indices array (indices(0) can only replace the first occurrence of #,
57  // indices(1) can only replace the second, etc.) If such a match is found,
58  // the work buffer will hold the corresponding reference channel, with first
59  // # replaced by the first UNUSED entry in indices, etc.
60  bool getReferencedChannel(const char* channel,
61  const UT_IntArray& indices,
62  UT_WorkBuffer& referenced) const;
63 
64  // Saves the opmultiparm commands required to set up the current
65  // set of references. The "opmultiparm" and node name parts of the
66  // command are not saved, and must be output before calling this
67  // funtion.
68  void saveCommands(std::ostream &os) const;
69 
70  // Saves the multiparm info as into a hip file.
71  void save(std::ostream &os, bool binary) const;
72 
73  // Loads multiparm info as from a hip file.
74  bool load(UT_IStream &is);
75 
76  // Save undo block
77  void saveForUndo();
78 
79  // Tries to match a specific channel name (instancechannel) with a
80  // generic channel name containing "#"s (genericinstancechannel).
81  // The numeric replacements required to match the channel names
82  // are stored in the hashreplacements array.
83  static bool matchChannels(const char *instancechannel,
84  const char *genericinstancechannel,
85  UT_IntArray &hashreplacements);
86 
87  int64 getMemoryUsage(bool inclusive) const
88  {
89  int64 mem = inclusive ? sizeof(*this) : 0;
90  mem += myInstanceChannels.getMemoryUsage(false);
91  mem += myReferencedChannels.getMemoryUsage(false);
92  return mem;
93  }
94 
95  class Undo;
96  friend class Undo;
97 
98 private:
99  OP_Parameters &myOwner;
100  UT_StringArray myInstanceChannels;
101  UT_StringArray myReferencedChannels;
102 };
103 
104 #endif
105 
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