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_SpareParms.h ( OP Library, C++) 00014 * 00015 * COMMENTS: Cache of spare parameter dialog scripts. Each cache entry has: 00016 * - The PRM_ScriptPage 00017 * - The PRM_ScriptImports 00018 * - The PRM_Template list 00019 * 00020 * This class is kept in a per-operator cache, allowing multiple nodes to 00021 * share templates etc. if they have the same spare parameters. 00022 */ 00023 00024 #ifndef __OP_SpareParms__ 00025 #define __OP_SpareParms__ 00026 00027 #include "OP_API.h" 00028 #include <SYS/SYS_Types.h> 00029 #include <UT/UT_String.h> 00030 #include <UT/UT_HashTable.h> 00031 #include <PRM/PRM_Default.h> 00032 00033 class UT_IntArray; 00034 class UT_IStream; 00035 class OP_SpareParmCache; 00036 class OP_Operator; 00037 class PRM_ScriptPage; 00038 class PRM_ScriptImports; 00039 class PRM_Template; 00040 00041 class OP_API OP_SpareParms 00042 { 00043 public: 00044 OP_SpareParms(OP_SpareParmCache *cache, 00045 UT_IStream &is, 00046 OP_Operator *op, 00047 const char *key); 00048 00049 bool isValid() const { return myPage != 0; } 00050 int bumpRef(int dir); 00051 PRM_ScriptPage *getScriptPage() { return myPage; } 00052 PRM_Template *getSpareTemplates() { return mySpareTemplates; } 00053 PRM_Template *getLayoutTemplates() { return myLayoutTemplates; } 00054 PRM_ScriptImports *getImports() { return myImports; } 00055 const char *getKey() { return myKey; } 00056 00057 // The Id for this class is a unique integer value >= 0 that allows us 00058 // to safely and uniquely identify an instance of this class without 00059 // worrying about pointer reuse. 00060 int getId() const { return myId; } 00061 00062 private: 00063 // These should only be deleted through bumpRef calls. 00064 ~OP_SpareParms(); 00065 00066 // Turn our parsed script into spare and layout template arrays. We use 00067 // the operator to supply the base parameter information. 00068 void createTemplates(OP_Operator *op); 00069 // Use the base templates to fix up the layout templates, and possibly 00070 // fill in a spare templates array. Works for top level or multiparm 00071 // templates. Returns true if the layout templates and base templates 00072 // are exactly the same. 00073 bool createTemplates(PRM_Template *basetplate, 00074 PRM_Template *laytplate, 00075 PRM_Template *sparetplate, 00076 bool doingmultiparm); 00077 // Clears the key value, for when we stash this spare parms. 00078 void clearKey(); 00079 00080 OP_SpareParmCache *myCache; 00081 PRM_ScriptPage *myPage; 00082 PRM_ScriptImports *myImports; 00083 PRM_Template *mySpareTemplates; 00084 PRM_Template *myLayoutTemplates; 00085 PRM_Default myStandardFolderDefaults[2]; 00086 PRM_Default myEmptyFolderDefaults[2]; 00087 UT_String myKey; 00088 int myRefCount; 00089 int myId; 00090 00091 friend class OP_SpareParmCache; 00092 }; 00093 00094 class OP_API OP_SpareParmCache 00095 { 00096 public: 00097 OP_SpareParmCache(); 00098 00099 OP_SpareParms *createSpareParms(UT_IStream &is, OP_Operator *op); 00100 00101 // Called only by bumpRef() 00102 void removeSpareParms(OP_SpareParms *parms); 00103 00104 // Increment or decrement the ref count on this cache. 00105 int bumpRef(int dir); 00106 00107 // Move all our spare parms from myCache into myStash. 00108 void stashSpareParms(); 00109 00110 // Recreate the parm templates for all OP_SpareParms in this cache. 00111 void recreateStashedSpareParms(OP_Operator *op); 00112 00113 private: 00114 // These should only be deleted through bumpRef calls. 00115 ~OP_SpareParmCache(); 00116 00117 UT_HashTable myCache; 00118 UT_PtrArray<OP_SpareParms *> myStash; 00119 int myRefCount; 00120 }; 00121 00122 #endif 00123
1.5.9