All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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: VOP Library (C++)
7  *
8  * Note: This is more of an internal class, not an actual node. It needs to inherit
9  * from VOP_Node to generate code properly, though. What happens is during code
10  * generation, copies of it are inserted into the flattened node list, and (before
11  * they are inserted) are told which two nodes and which input/output they go between.
12  * Thus, these are essentially virtual nodes that get created only at code generation
13  * time and destroyed immediately afterwards.
14  *
15  * During code generation, they pretend they really are connected between the two nodes,
16  * and generate proper auto-conversion code. Auto convert also contains severa static
17  * functions that determine whether two types can be auto-converted between.
18  *
19  */
21 #ifndef __VOP_AutoConvert_h__
22 #define __VOP_AutoConvert_h__
24 #include "VOP_API.h"
25 #include "VOP_Node.h"
26 #include <string>
31 {
32 public:
34  virtual ~VOP_AutoConvert();
36  /// Returns true if intype can be converted to outtype.
37  static bool canAutoconvert(VOP_Type intype, VOP_Type outtype,
38  const VOP_Language *language);
39  static bool canAutoconvert(const VOP_TypeInfo &intype,
40  const VOP_TypeInfo &outtype,
41  const VOP_Language *language);
43  // Since this "node" is meant to be used on its own, we override this
44  // to let VEX code be generated properly.
45  virtual void getPathWithSubnet(UT_String &str) const;
46  virtual void getOuterCode(UT_String &codestr,
47  const VOP_CodeGenContext &context);
48  virtual void getCode(UT_String &codestr,
49  const VOP_CodeGenContext &context);
51  virtual OP_Network *getParentNetwork() const;
53  virtual OP_Input *getInputReference(unsigned idx, bool grow);
54  virtual OP_Input *getInputReferenceConst(unsigned idx) const;
56  void hookupBetween(VOP_Node* input_node, VOP_Node* output_node,
57  int input_idx, bool tell_nodes);
59  virtual bool isConnected(int inputidx, bool recursive);
60  virtual unsigned getNumVisibleInputs() const;
61  virtual unsigned getNumVisibleOutputs() const;
62  virtual const char *inputLabel(unsigned idx) const;
63  virtual const char *outputLabel(unsigned idx) const;
65  static void initConversions(void);
67  static const char* getAutoConvertOpName(const VOP_TypeInfo &from_type,
68  const VOP_TypeInfo &to_type);
69  static const char* getAutoConvertOpName(VOP_Type from_type, VOP_Type to_type);
70  static VOP_Type generateCodeFor(VOP_Node *input_node,
71  VOP_Node *output_node,
72  int input_idx, UT_String &codestr,
73  bool current_types_only);
75  virtual bool isAutoConvertNode() const
76  { return true; }
78 protected:
80  virtual void getInputNameSubclass(UT_String &in, int idx) const;
81  virtual int getInputFromNameSubclass(const UT_String &in) const;
82  virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info,
83  int idx);
85  virtual void getOutputNameSubclass(UT_String &out, int idx) const;
86  virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info,
87  int idx);
89  static void getConversionBetween(VOP_Type intype, VOP_Type outtype,
90  std::string& out, const VOP_Language *language);
92 private:
95  // Since autoconversion nodes are only created when generating
96  // code, we can just keep the pointers. Also, we can't use setInput(), etc.
97  // because that will modify the actual node graph, and disconnect previous nodes.
98  // We don't want to do that.
99  VOP_Node *myInput, *myOutput;
100  int myInputIdx; // input index on the node we output to
102  // From-to-type.
103  static std::string theConversionTable[VOP_MAX_TYPES][VOP_MAX_TYPES];
104  static bool theDidInitConversions;
105  static std::string theConversionNodeNameTable[VOP_MAX_TYPES][VOP_MAX_TYPES];
107  VOP_TypeInfo myConvertedOutputTypeInfo;
108 };
110 #endif
virtual int getInputFromNameSubclass(const UT_String &in) const
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:27
virtual void getOuterCode(UT_String &codestr, const VOP_CodeGenContext &context)
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
virtual unsigned getNumVisibleInputs() const
virtual OP_Input * getInputReferenceConst(unsigned idx) const
virtual const char * inputLabel(unsigned idx) const
virtual unsigned getNumVisibleOutputs() const
virtual void getPathWithSubnet(UT_String &str) const
Returns the path of this node relative to its getCreator()
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual bool isConnected(int inputidx, bool recursive)
#define VOP_API
Definition: VOP_API.h:10
virtual void getCode(UT_String &codestr, const VOP_CodeGenContext &context)
Get the code fragment to be included in the shader code.
virtual const char * outputLabel(unsigned idx) const
virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void getOutputNameSubclass(UT_String &out, int idx) const
virtual OP_Input * getInputReference(unsigned idx, bool grow)
Definition: VOP_Types.h:24
virtual void getInputNameSubclass(UT_String &in, int idx) const
virtual OP_Network * getParentNetwork() const
Returns the network that is our parent.
virtual bool isAutoConvertNode() const
Retruns true if the node is an internal auto-convert node.