00001 /* 00002 * Copyright (c) 2012 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #ifndef __VOP_Switch_h__ 00027 #define __VOP_Switch_h__ 00028 00029 #include <VOP/VOP_Node.h> 00030 00031 /// @file 00032 /// This example contains code which shows how to perform some of the most 00033 /// common tasks when writing a custom VEX code operator. It produces code 00034 /// which selects one of the inputs to feed to the output. 00035 namespace HDK_Sample { 00036 00037 /// C++ VOP node to select one of its inputs and feed it into the output. 00038 class VOP_Switch : public VOP_Node 00039 { 00040 public: 00041 /// Creates an instance of this node with the given name in the given network. 00042 static OP_Node *myConstructor(OP_Network *net, 00043 const char *name, 00044 OP_Operator *entry); 00045 00046 /// Our parameter templates. 00047 static PRM_Template myTemplateList[]; 00048 00049 /// Disable our parameters based on which inputs are connected. 00050 virtual unsigned disableParms(); 00051 00052 /// Generate the code for this operator. 00053 virtual void getCode(UT_String &codestr); 00054 00055 /// Provides the labels to appear on input and output buttons. 00056 virtual const char *inputLabel(unsigned idx) const; 00057 virtual const char *outputLabel(unsigned idx) const; 00058 00059 /// Controls the number of input buttons visible on the node tile. 00060 virtual unsigned getNumVisibleInputs() const; 00061 00062 /// Returns the index of the first "unordered" input, meaning that inputs 00063 /// before this one should not be collapsed when they are disconnected. 00064 virtual unsigned orderedInputs() const; 00065 00066 protected: 00067 VOP_Switch(OP_Network *net, const char *name, OP_Operator *entry); 00068 virtual ~VOP_Switch(); 00069 00070 /// Returns the internal name of the supplied input. This input name is 00071 /// used when the code generator substitutes variables return by getCode. 00072 virtual void getInputNameSubclass(UT_String &in, int idx) const; 00073 /// Reverse mapping of internal input names to an input index. 00074 virtual int getInputFromNameSubclass(const UT_String &in) const; 00075 /// Returns the data type that must be connected to the supplied input. 00076 virtual VOP_Type getInputTypeSubclass(int idx); 00077 00078 /// Returns the internal name of the supplied output. This name is used 00079 /// when the code generator substitutes variables return by getCode. 00080 virtual void getOutputNameSubclass(UT_String &out, int idx) const; 00081 /// Returns the data type of each output connector. 00082 virtual VOP_Type getOutputTypeSubclass(int idx); 00083 /// This methods should be overriden in most VOP nodes. It should fill 00084 /// in voptypes vector with vop types that are allowed to be connected 00085 /// to this node at the input at index idx. Note that unlike getInputTypeSubclass(), 00086 /// this method should return valid vop types even when nothing is 00087 /// connected to the corresponding input. 00088 void getAllowedInputTypesSubclass(unsigned idx, VOP_VopTypeArray &voptypes); 00089 00090 /// Accesses the parameter that controls how out of bounds switch indices 00091 /// are handled. 00092 int OUTOFBOUNDS(); 00093 }; 00094 00095 } // End of HDK_Sample namespace 00096 00097 #endif
1.5.9