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_PropertyLookupList.h ( OP Library, C++) 00014 * 00015 * COMMENTS: Class used to perform batch lookup of parameters/properties. 00016 * The list should be initialized with the parameter names. 00017 * Calling OP_Parameters::lookupParameterOrProperties() will fill 00018 * out the objects and parameter information. 00019 */ 00020 00021 #ifndef __OP_PropertyLookupList__ 00022 #define __OP_PropertyLookupList__ 00023 00024 #include "OP_API.h" 00025 00026 #include <UT/UT_PtrArray.h> 00027 00028 class OP_Node; 00029 class PRM_Parm; 00030 00031 class OP_API OP_PropertyLookupList { 00032 public: 00033 OP_PropertyLookupList() {} 00034 ~OP_PropertyLookupList() {} 00035 00036 void reserve(int size) // Reserve space for parameters 00037 { 00038 myNames.resizeIfNeeded(size); 00039 mySrcNodes.resizeIfNeeded(size); 00040 myNodes.resizeIfNeeded(size); 00041 myParmPtrs.resizeIfNeeded(size); 00042 myLookupData.resizeIfNeeded(size); 00043 } 00044 void clear() 00045 { 00046 myNames.entries(0); 00047 mySrcNodes.entries(0); 00048 myNodes.entries(0); 00049 myParmPtrs.entries(0); 00050 myLookupData.entries(0); 00051 } 00052 00053 // The names are passed by reference and must be maintained by the caller. 00054 // The strings are *not* duplicated in this list. 00055 void addParm(const char *name, OP_Node *src, void *data) 00056 { 00057 myNames.append(name); 00058 mySrcNodes.append(src); 00059 myNodes.append((OP_Node *)0); 00060 myParmPtrs.append((PRM_Parm *)0); 00061 myLookupData.append(data); 00062 } 00063 int entries() const { return myNames.entries(); } 00064 const char *getName(int i) const { return myNames(i); } 00065 OP_Node *getSourceNode(int i) const { return mySrcNodes(i); } 00066 00067 // After the lookup has been performed, the following methods may be called 00068 bool isFound(int i) const { return myNodes(i) != 0; } 00069 OP_Node *getNode(int i) const { return myNodes(i); } 00070 PRM_Parm *getParmPtr(int i) const { return myParmPtrs(i); } 00071 void *getLookupData(int i) const { return myLookupData(i); } 00072 00073 // The following method is 00074 void setLookupInfo(int i, OP_Node *node, PRM_Parm *parm) 00075 { 00076 UT_ASSERT(i >= 0 && i < myNodes.entries()); 00077 myNodes(i) = node; 00078 myParmPtrs(i) = parm; 00079 } 00080 00081 private: 00082 UT_PtrArray<const char *> myNames; 00083 UT_PtrArray<OP_Node *> mySrcNodes; 00084 UT_PtrArray<OP_Node *> myNodes; 00085 UT_PtrArray<PRM_Parm *> myParmPtrs; 00086 UT_PtrArray<void *> myLookupData; 00087 }; 00088 00089 #endif
1.5.9