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 "OP_OTLDefinition.h"
00027
00028 #define OTL_LIBRARY_PREFIX "oplib:"
00029 #define OTL_DEFINITION_PREFIX "opdef:"
00030 #define OTL_DS_SECTION "DialogScript"
00031 #define OTL_CREATESCRIPT_SECTION "CreateScript"
00032 #define OTL_CONTENTS_SECTION "Contents"
00033 #define OTL_CONTENTS_GZ_SECTION "Contents.gz"
00034 #define OTL_EDITABLE_SUBNODES_SECTION "EditableNodes"
00035 #define OTL_SELECTORS_SECTION "Selectors"
00036 #define OTL_SHELFTOOLS_SECTION "Tools.shelf"
00037 #define OTL_VEX_SECTION "VexCode"
00038 #define OTL_PYTHON_COOK_SECTION "PythonCook"
00039 #define OTL_VFL_SECTION "VflCode"
00040 #define OTL_HELP_SECTION "Help"
00041 #define OTL_HELPURL_SECTION "HelpUrl"
00042 #define OTL_ICON_SECTION "Icon"
00043 #define OTL_ICONIMAGE_SECTION "IconImage"
00044 #define OTL_ICONSVG_SECTION "IconSVG"
00045 #define OTL_PRESETS_SECTION "Presets"
00046 #define OTL_COMMENT_SECTION "Comment"
00047 #define OTL_VERSION_SECTION "Version"
00048 #define OTL_EXPRESSIONS_SECTION "Expressions"
00049 #define OTL_PYTHONMODULE_SECTION "PythonModule"
00050 #define OTL_PREFIRSTCREATE_SECTION "PreFirstCreate"
00051 #define OTL_ONCREATED_SECTION "OnCreated"
00052 #define OTL_ONLOADED_SECTION "OnLoaded"
00053 #define OTL_ONUPDATED_SECTION "OnUpdated"
00054 #define OTL_ONDELETED_SECTION "OnDeleted"
00055 #define OTL_POSTLASTDELETE_SECTION "PostLastDelete"
00056 #define OTL_ONINPUTCHANGED_SECTION "OnInputChanged"
00057 #define OTL_ONNAMECHANGED_SECTION "OnNameChanged"
00058 #define OTL_TYPEPROPOPTIONS_SECTION "TypePropertiesOptions"
00059 #define OTL_EXTRAFILEOPTIONS_SECTION "ExtraFileOptions"
00060 #define OTL_SDLAYOUT_SECTION "SDLayout"
00061 #define OTL_CPLAYOUT_SECTION "CPLayout"
00062 #define OTL_CPIMAGE_SECTION "CPImage"
00063 #define OTL_GALLERY_SECTION "Gallery"
00064 #define OTL_GLSL_VERTEX_SECTION "GlslVertex"
00065 #define OTL_GLSL_FRAGMENT_SECTION "GlslFragment"
00066
00067 #define OTL_INTERNAL "Embedded"
00068 #define OTL_INTERNAL_META "Current HIP File"
00069 #define OTL_FALLBACK_META "Fallback Libraries"
00070 #define OTL_OTLSCAN_META "Scanned OTL Directories"
00071
00072 class OP_API OP_OTLLibrary : public FS_IndexFile
00073 {
00074 public:
00075 OP_OTLLibrary();
00076 OP_OTLLibrary(FS_Reader *reader);
00077 OP_OTLLibrary(const char *source, const char *metasrc);
00078 virtual ~OP_OTLLibrary();
00079
00080 const UT_String &getMetaSource() const;
00081 const UT_String &getSource() const;
00082
00083 enum OP_ModTimeStatus
00084 {
00085 MOD_TIME_OK,
00086 MOD_TIME_INTERNAL,
00087 MOD_TIME_SAVE_QUIT,
00088 MOD_TIME_DISCARD_QUIT,
00089 MOD_TIME_EMBED
00090 };
00091
00092
00093
00094
00095
00096
00097
00098
00099 OP_ModTimeStatus getSourceModTime( int &mod_time ) const;
00100
00101 bool addDefinition(const OP_OTLDefinition &definition,
00102 int modtime = -1);
00103 bool removeDefinition(int index);
00104
00105 int getNumDefinitions() const;
00106 int getDefinitionIndex(const char *tablename,
00107 const char *opname) const;
00108 int getDefinitionModTime(int index) const;
00109 const UT_String &getDefinitionName(int index) const;
00110 const UT_String &getDefinitionOpTableName(int index) const;
00111 bool getDefinitionIsDummy(int index) const;
00112 bool getDefinition(int index,
00113 OP_OTLDefinition &definition) const;
00114
00115 void mergeLibrary(const OP_OTLLibrary &lib);
00116
00117 virtual bool expandToDirectory(const char *destdir);
00118 virtual bool collapseFromDirectory(const char *srcdir);
00119 virtual void writeFile(ostream &os);
00120
00121 void setIsBeingRefreshed(bool beingrefreshed);
00122 bool getIsBeingRefreshed() const;
00123
00124 static bool createBackupFile(const char *filename);
00125 static bool isReservedSectionName(const char *sectname);
00126 static const char *getEventName(int index);
00127 static const char *getEventSectionName(int index);
00128
00129 private:
00130 void readDefinitions();
00131 void saveDefinitionsToSection(bool binary);
00132
00133 static const char *getTableSymbol(const char *table, const char *op);
00134
00135 const UT_String mySource;
00136 const UT_String myMetaSource;
00137 OP_OTLDefinitionArray myDefinitions;
00138 UT_SymbolTable myDefinitionTable;
00139 bool myIsBeingRefreshed;
00140 };
00141
00142 #endif
00143