00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __OP_OTLLibrary__
00020 #define __OP_OTLLibrary__
00021
00022 #include "OP_API.h"
00023 #include <UT/UT_String.h>
00024 #include <UT/UT_SymbolTable.h>
00025 #include <FS/FS_IndexFile.h>
00026 #include <VEX/VEX_VexTypes.h>
00027 #include "OP_OTLDefinition.h"
00028
00029 #define OTL_LIBRARY_PREFIX "oplib:"
00030 #define OTL_DEFINITION_PREFIX "opdef:"
00031 #define OTL_DS_SECTION "DialogScript"
00032 #define OTL_CREATESCRIPT_SECTION "CreateScript"
00033 #define OTL_CONTENTS_SECTION "Contents"
00034 #define OTL_CONTENTS_GZ_SECTION "Contents.gz"
00035 #define OTL_EDITABLE_SUBNODES_SECTION "EditableNodes"
00036 #define OTL_MESSAGE_SUBNODES_SECTION "MessageNodes"
00037 #define OTL_SELECTORS_SECTION "Selectors"
00038 #define OTL_SHELFTOOLS_SECTION "Tools.shelf"
00039 #define OTL_VEX_SECTION "VexCode"
00040 #define OTL_PYTHON_COOK_SECTION "PythonCook"
00041 #define OTL_VFL_SECTION "VflCode"
00042 #define OTL_HELP_SECTION "Help"
00043 #define OTL_HELPURL_SECTION "HelpUrl"
00044 #define OTL_ICON_SECTION "Icon"
00045 #define OTL_ICONIMAGE_SECTION "IconImage"
00046 #define OTL_ICONSVG_SECTION "IconSVG"
00047 #define OTL_PRESETS_SECTION "Presets"
00048 #define OTL_COMMENT_SECTION "Comment"
00049 #define OTL_VERSION_SECTION "Version"
00050 #define OTL_EXPRESSIONS_SECTION "Expressions"
00051 #define OTL_PYTHONMODULE_SECTION "PythonModule"
00052 #define OTL_PREFIRSTCREATE_SECTION "PreFirstCreate"
00053 #define OTL_ONCREATED_SECTION "OnCreated"
00054 #define OTL_ONLOADED_SECTION "OnLoaded"
00055 #define OTL_ONUPDATED_SECTION "OnUpdated"
00056 #define OTL_ONDELETED_SECTION "OnDeleted"
00057 #define OTL_POSTLASTDELETE_SECTION "PostLastDelete"
00058 #define OTL_ONINPUTCHANGED_SECTION "OnInputChanged"
00059 #define OTL_ONNAMECHANGED_SECTION "OnNameChanged"
00060 #define OTL_TYPEPROPOPTIONS_SECTION "TypePropertiesOptions"
00061 #define OTL_EXTRAFILEOPTIONS_SECTION "ExtraFileOptions"
00062 #define OTL_SDLAYOUT_SECTION "SDLayout"
00063 #define OTL_CPLAYOUT_SECTION "CPLayout"
00064 #define OTL_CPIMAGE_SECTION "CPImage"
00065 #define OTL_GALLERY_SECTION "Gallery"
00066 #define OTL_GLSL_VERTEX_SECTION "GlslVertex"
00067 #define OTL_GLSL_FRAGMENT_SECTION "GlslFragment"
00068 #define OTL_SCRIPT_MAT_INFO_SECTION "ScriptMaterialInfo"
00069
00070 #define OTL_VEX_SECTION_SUFFIX OTL_VEX_SECTION
00071 #define OTL_VFL_SECTION_SUFFIX OTL_VFL_SECTION
00072
00073 #define OTL_SURFACE_VEX_SECTION "Surface"OTL_VEX_SECTION_SUFFIX
00074 #define OTL_SURFACE_VFL_SECTION "Surface"OTL_VFL_SECTION_SUFFIX
00075 #define OTL_DISPLACE_VEX_SECTION "Displacement"OTL_VEX_SECTION_SUFFIX
00076 #define OTL_DISPLACE_VFL_SECTION "Displacement"OTL_VFL_SECTION_SUFFIX
00077 #define OTL_LIGHT_VEX_SECTION "Light"OTL_VEX_SECTION_SUFFIX
00078 #define OTL_LIGHT_VFL_SECTION "Light"OTL_VFL_SECTION_SUFFIX
00079 #define OTL_SHADOW_VEX_SECTION "Shadow"OTL_VEX_SECTION_SUFFIX
00080 #define OTL_SHADOW_VFL_SECTION "Shadow"OTL_VFL_SECTION_SUFFIX
00081 #define OTL_FOG_VEX_SECTION "Fog"OTL_VEX_SECTION_SUFFIX
00082 #define OTL_FOG_VFL_SECTION "Fog"OTL_VFL_SECTION_SUFFIX
00083 #define OTL_PHOTON_VEX_SECTION "Photon"OTL_VEX_SECTION_SUFFIX
00084 #define OTL_PHOTON_VFL_SECTION "Photon"OTL_VFL_SECTION_SUFFIX
00085 #define OTL_CHOP_VEX_SECTION "Chop"OTL_VEX_SECTION_SUFFIX
00086 #define OTL_CHOP_VFL_SECTION "Chop"OTL_VFL_SECTION_SUFFIX
00087 #define OTL_POP_VEX_SECTION "Pop"OTL_VEX_SECTION_SUFFIX
00088 #define OTL_POP_VFL_SECTION "Pop"OTL_VFL_SECTION_SUFFIX
00089 #define OTL_SOP_VEX_SECTION "Sop"OTL_VEX_SECTION_SUFFIX
00090 #define OTL_SOP_VFL_SECTION "Sop"OTL_VFL_SECTION_SUFFIX
00091 #define OTL_COP2_VEX_SECTION "Cop2"OTL_VEX_SECTION_SUFFIX
00092 #define OTL_COP2_VFL_SECTION "Cop2"OTL_VFL_SECTION_SUFFIX
00093 #define OTL_I3D_VEX_SECTION "Image3d"OTL_VEX_SECTION_SUFFIX
00094 #define OTL_I3D_VFL_SECTION "Image3d"OTL_VFL_SECTION_SUFFIX
00095 #define OTL_CVEX_VEX_SECTION "CVex"OTL_VEX_SECTION_SUFFIX
00096 #define OTL_CVEX_VFL_SECTION "CVex"OTL_VFL_SECTION_SUFFIX
00097
00098
00099 #define OTL_INTERNAL "Embedded"
00100 #define OTL_INTERNAL_META "Current HIP File"
00101 #define OTL_FALLBACK_META "Fallback Libraries"
00102 #define OTL_OTLSCAN_META "Scanned OTL Directories"
00103
00104
00105
00106 class OP_API OP_OTLLibrary : public FS_IndexFile
00107 {
00108 public:
00109 OP_OTLLibrary();
00110 OP_OTLLibrary(FS_Reader *reader);
00111 OP_OTLLibrary(const char *source, const char *metasrc);
00112 virtual ~OP_OTLLibrary();
00113
00114 const UT_String &getMetaSource() const;
00115 const UT_String &getSource() const;
00116
00117 enum OP_ModTimeStatus
00118 {
00119 MOD_TIME_OK,
00120 MOD_TIME_INTERNAL,
00121 MOD_TIME_SAVE_QUIT,
00122 MOD_TIME_DISCARD_QUIT,
00123 MOD_TIME_EMBED
00124 };
00125
00126
00127
00128
00129 static bool forceOTLExtension(UT_String &filename);
00130
00131
00132
00133 static void getVexAndVflSectionNames( const char * suggestion,
00134 UT_String & vexsect, UT_String & vflsect);
00135
00136
00137
00138
00139
00140
00141
00142
00143 OP_ModTimeStatus getSourceModTime( int &mod_time ) const;
00144
00145 bool addDefinition(const OP_OTLDefinition &definition,
00146 int modtime = -1);
00147 bool removeDefinition(int index);
00148
00149 int getNumDefinitions() const;
00150 int getDefinitionIndex(const char *tablename,
00151 const char *opname) const;
00152 int getDefinitionModTime(int index) const;
00153 const UT_String &getDefinitionName(int index) const;
00154 const UT_String &getDefinitionOpTableName(int index) const;
00155 bool getDefinitionIsDummy(int index) const;
00156 bool getDefinition(int index,
00157 OP_OTLDefinition &definition) const;
00158
00159 void mergeLibrary(const OP_OTLLibrary &lib);
00160
00161 virtual bool expandToDirectory(const char *destdir);
00162 virtual bool collapseFromDirectory(const char *srcdir);
00163 virtual void writeFile(ostream &os);
00164
00165 void setIsBeingRefreshed(bool beingrefreshed);
00166 bool getIsBeingRefreshed() const;
00167
00168 static bool createBackupFile(const char *filename);
00169 static bool isReservedSectionName(const char *sectname);
00170 static const char *getEventName(int index);
00171 static const char *getEventSectionName(int index);
00172
00173 static const char *getVexCodeSectionName(VEX_ContextType type);
00174 static const char *getVflCodeSectionName(VEX_ContextType type);
00175
00176 private:
00177 void readDefinitions();
00178 void saveDefinitionsToSection(bool binary);
00179
00180 static const char *getTableSymbol(const char *table, const char *op);
00181
00182 const UT_String mySource;
00183 const UT_String myMetaSource;
00184 OP_OTLDefinitionArray myDefinitions;
00185 UT_SymbolTable myDefinitionTable;
00186 bool myIsBeingRefreshed;
00187 };
00188
00189 #endif
00190