cgma
CubitFileMetaData.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002     COPYRIGHT 2002 CATERPILLAR INC.  ALL RIGHTS RESERVED
00003 
00004     This program is the property of Caterpillar Inc., includes Caterpillar's
00005     confidential and trade secret information, and is maintained as an
00006     unpublished copyrighted work.  It is not to be copied or used by others
00007     except under license from Caterpillar.  This program is also protected as an
00008     unpublished work in accordance with the copyright act of 1976.  In the event
00009     of either inadvertent or deliberate publication, Caterpillar Inc. intends to
00010     maintain copyright protection for this work under the relevant copyright
00011     laws pertaining to published works.  The inclusion of a copyright notice
00012     hereon is precautionary only, and does not imply publication or disclosure.
00013 
00014  
00015  Filename      : CubitFileMetaData.hpp
00016 
00017  Purpose       : Declares a meta-data (descriptions) management interface for
00018                  the Cubit (*.cub) format file.
00019            
00020  Special Notes :
00021 
00022  Creator       : Will A. Helden
00023 
00024  Creation Date : 02/15/02
00025 
00026  Owner         : Will A. Helden
00027 
00028 *******************************************************************************/
00029 
00030 #ifndef CubitFileMetaData_HPP
00031 #define CubitFileMetaData_HPP
00032 
00033 #include "CCubitFile.hpp"
00034 #include "CGMUtilConfigure.h"
00035 
00036 namespace NCubitFile {
00037 
00038 typedef const UnsignedInt32* ConstUnsignedInt32Ptr;
00039 typedef const double* ConstDoublePtr;
00040 
00041 class CUBIT_UTIL_EXPORT CMetaData {
00042 public:
00043     CMetaData(UnsignedInt32 xintGrowSizeBy = 64);
00044     virtual ~CMetaData();
00045     
00046     UnsignedInt32 GetValue(UnsignedInt32 xintOwner,
00047         ConstCharPtr xpachrName, UnsignedInt32& xintValue);
00048     UnsignedInt32 GetValue(UnsignedInt32 xintOwner,
00049         ConstCharPtr xpachrName, ConstCharPtr& xpachrValue);
00050     UnsignedInt32 GetValue(UnsignedInt32 xintOwner,
00051         ConstCharPtr xpachrName, double& xdblValue);
00052     UnsignedInt32 GetValue(UnsignedInt32 xintOwner,
00053         ConstCharPtr xpachrName, const UnsignedInt32*& xpaintValue,
00054         UnsignedInt32& xintNumValues);
00055     UnsignedInt32 GetValue(UnsignedInt32 xintOwner,
00056         ConstCharPtr xpachrName, const double*& xpadblValue,
00057         UnsignedInt32& xintNumValues);
00058 
00059     UnsignedInt32 SetValue(UnsignedInt32 xintOwner,
00060         ConstCharPtr xpachrName, UnsignedInt32 xintValue);
00061     UnsignedInt32 SetValue(UnsignedInt32 xintOwner,
00062         ConstCharPtr xpachrName, ConstCharPtr xpachrValue);
00063     UnsignedInt32 SetValue(UnsignedInt32 xintOwner,
00064         ConstCharPtr xpachrName, double xdblValue);
00065     UnsignedInt32 SetValue(UnsignedInt32 xintOwner,
00066         ConstCharPtr xpachrName, const UnsignedInt32* xpaintValue,
00067         UnsignedInt32 xintNumValues);
00068     UnsignedInt32 SetValue(UnsignedInt32 xintOwner,
00069         ConstCharPtr xpachrName, const double* xpadblValue,
00070         UnsignedInt32 xintNumValues);
00071     
00072     UnsignedInt32 ClearMetaDataForID(UnsignedInt32 xintOwner);
00073 
00074     UnsignedInt32 GetMetaDataAll(UnsignedInt32& xintNumFound,
00075         const ConstCharPtr*& xpapachrName, const UnsignedInt32*& xpaintOwner,
00076         const UnsignedInt32*& xpaintValue);
00077     UnsignedInt32 GetMetaDataAll(UnsignedInt32& xintNumFound,
00078         const ConstCharPtr*& xpapachrName, const UnsignedInt32*& xpaintOwner,
00079         const ConstCharPtr*& xpapachrValue);
00080     UnsignedInt32 GetMetaDataAll(UnsignedInt32& xintNumFound,
00081         const ConstCharPtr*& xpapachrName, const UnsignedInt32*& xpaintOwner,
00082         const double*& xpadblValue);
00083     UnsignedInt32 GetMetaDataAll(UnsignedInt32& xintNumFound,
00084         const ConstCharPtr*& xpapachrName, const UnsignedInt32*& xpaintOwner,
00085         const ConstUnsignedInt32Ptr*& xpapaintValue,
00086         const UnsignedInt32*& xpaintNumValues);
00087     UnsignedInt32 GetMetaDataAll(UnsignedInt32& xintNumFound,
00088         const ConstCharPtr*& xpapachrName, const UnsignedInt32*& xpaintOwner,
00089         const ConstDoublePtr*& xpapadblValue,
00090         const UnsignedInt32*& xpaintNumValues);
00091     
00092     void WriteMetaData(FILE* xpFile,
00093         UnsignedInt32& xintWroteAtOffset,
00094         UnsignedInt32& xintLength,
00095         UnsignedInt32 xintOffsetFrom = 0);
00096     void ReadMetaData(FILE* xpFile,
00097         UnsignedInt32 xintAbsoluteOffset,
00098         UnsignedInt32 xintRelativeOffset,
00099         UnsignedInt32 xintSourceEndian);
00100 
00101 private:
00102     enum EMetaDataType { eUnsignedInt32, eString, eDouble,
00103         eUnsignedInt32Array, eDoubleArray };
00104 
00105     void GrowSize();
00106     UnsignedInt32 Find(UnsignedInt32 xintOwner,
00107         ConstCharPtr xpachrName, UnsignedInt32& xintIndex);
00108     void FreeAll();
00109     void FreeAt(UnsignedInt32 xintEntry);
00110     void FreeValueAt(UnsignedInt32 xintEntry);
00111     UnsignedInt32 AddEntry(UnsignedInt32 xintOwner, ConstCharPtr xpachrName);
00112     void RebuildSearchBuff(UnsignedInt32 xintSearchType);
00113     UnsignedInt32 SearchByID(UnsignedInt32 xintSearchType,
00114         UnsignedInt32 xintOwner);
00115     UnsignedInt32 SearchByName(UnsignedInt32 xintSearchType,
00116         const char* xpachrName);
00117     UnsignedInt32 SearchAll(UnsignedInt32 xintSearchType);
00118     
00119     struct SCubitFileMetaDataHeader {
00120         UnsignedInt32 mintMetaDataSchema;
00121         UnsignedInt32 mintMetaDataCompress;
00122         UnsignedInt32 mintMetaDataCount;
00123     } mHeader;
00124     struct SCubitFileMetaDataEntry {
00125         UnsignedInt32 mintMetaDataOwner;
00126         UnsignedInt32 mintMetaDataType;
00127         char* mpachrName;
00128         union {
00129             UnsignedInt32 mint;
00130             char* mpachr;
00131             double mdbl;
00132             UnsignedInt32* mpaint;
00133             double* mpadbl;
00134         } muValue;
00135         UnsignedInt32 mintNumValues;
00136     } *mpaEntries;
00137 
00138     UnsignedInt32 mintBufferSize;
00139     UnsignedInt32 mintGrowSizeBy;
00140 
00141     struct {
00142         UnsignedInt32 mintNumOwners;
00143         UnsignedInt32* mpaintOwners;
00144         UnsignedInt32 mintNumNames;
00145         ConstCharPtr* mpapachrNames;
00146         UnsignedInt32 mintMetaDataType;
00147         UnsignedInt32 mintNumMetaData;
00148         void* mpaValues;
00149         UnsignedInt32* mpaintNumValues;
00150     } mSearchBuff;
00151 };
00152 
00153 } // namespace NCubitFile
00154 
00155 #endif 
00156 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines