00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: OP_GlobalParam.h ( OP Library, C++) 00014 * 00015 * COMMENTS: This file contains accessors for global parameters. These 00016 * parameters make use of the stamp/param mechanism and allow for 00017 * proper propagation of changes. 00018 */ 00019 00020 #ifndef __OP_GlobalParam__ 00021 #define __OP_GlobalParam__ 00022 00023 #include "OP_API.h" 00024 #include <SYS/SYS_Types.h> 00025 #include <UT/UT_Thread.h> 00026 00027 enum { 00028 OP_GLOBAL_PARAM_INSTANCEPOINT 00029 }; 00030 00031 class OP_API OP_GlobalParam { 00032 public: 00033 static fpreal getInstancePoint(int thread, 00034 bool add_dependencies=true); 00035 static void setInstancePoint(int ptnum); 00036 }; 00037 00038 class OP_API OP_GlobalParamPusher { 00039 public: 00040 explicit OP_GlobalParamPusher(int param) 00041 : myParam(param) 00042 { 00043 switch (param) 00044 { 00045 case OP_GLOBAL_PARAM_INSTANCEPOINT: 00046 myIValue = (int)OP_GlobalParam::getInstancePoint(UTgetSTID(), 00047 false); 00048 break; 00049 } 00050 myChanged = false; 00051 } 00052 ~OP_GlobalParamPusher() 00053 { 00054 if (myChanged) 00055 { 00056 switch (myParam) 00057 { 00058 case OP_GLOBAL_PARAM_INSTANCEPOINT: 00059 OP_GlobalParam::setInstancePoint(myIValue); 00060 break; 00061 } 00062 } 00063 } 00064 void setIValue(int val) 00065 { 00066 switch (myParam) 00067 { 00068 case OP_GLOBAL_PARAM_INSTANCEPOINT: 00069 if (val != myIValue || myChanged) 00070 { 00071 OP_GlobalParam::setInstancePoint(val); 00072 myChanged = true; 00073 } 00074 break; 00075 } 00076 } 00077 int getIValue() const { return myIValue; } 00078 private: 00079 int myParam; 00080 int myIValue; 00081 bool myChanged; 00082 }; 00083 00084 #endif
1.5.9