deftypes.h

Go to the documentation of this file.
00001 
00006 /*
00007  *  Copyright (c) 2005, Matt Beard
00008  *
00009  *  This software is provided 'as-is', without any express or implied warranty.
00010  *  In no event will the authors be held liable for any damages arising from
00011  *  the use of this software.
00012  *
00013  *  Permission is granted to anyone to use this software for any purpose,
00014  *  including commercial applications, and to alter it and redistribute it
00015  *  freely, subject to the following restrictions:
00016  *
00017  *    1. The origin of this software must not be misrepresented; you must
00018  *       not claim that you wrote the original software. If you use this
00019  *       software in a product, an acknowledgment in the product
00020  *       documentation would be appreciated but is not required.
00021  *  
00022  *    2. Altered source versions must be plainly marked as such, and must
00023  *       not be misrepresented as being the original software.
00024  *  
00025  *    3. This notice may not be removed or altered from any source
00026  *       distribution.
00027  */
00028 #ifndef MXFLIB__DICTIONARY_H
00029 #define MXFLIB__DICTIONARY_H
00030 
00031 // STL Includes
00032 #include <string>
00033 #include <list>
00034 
00035 
00036 namespace mxflib
00037 {
00038     // DRAGONS: Why are there two different (but similar) in memory versions of type records?
00039     //          The answer is that as some types depend on others the loading process requires stacking
00040     //          part-processed entries for later completion. It is not easy to stack the simple struct
00041     //          version, partly because of the char pointers to strings and partly because of the fact
00042     //          that the compound sub-items are linked by their position in the array rather than a pointer
00043     //          giving ownership - however these same features are required in order to allow data to be
00044     //          built at compile-time which is highly desirable. When a type definition table made from
00045     //          the "constant" struct version is loaded it is first copied to a list of classes for easy
00046     //          manipulation during further processing.
00047 
00049     enum TypeClass
00050     {
00051         TypeNULL = 0,                       
00052         TypeBasic,                          
00053         TypeInterpretation,                 
00054         TypeMultiple,                       
00055         TypeCompound,                       
00056         TypeSub,                            
00057         TypeEnum,                           
00058         TypeLabel,                          
00059         TypeSymbolSpace                     
00060     };
00061 
00063     enum TypeRef
00064     {
00065         TypeRefUndefined = -1,              
00066         TypeRefNone = 0,                    
00067         TypeRefStrong,                      
00068         TypeRefWeak,                        
00069         TypeRefTarget,                      
00070         TypeRefGlobal                       
00071     };
00072 
00074     struct ConstTypeRecord
00075     {
00076         TypeClass Class;                    
00077         const char *Type;                   
00078         const char *Detail;                 
00079         const char *Base;                   
00080         const char *UL;                     
00081         const char *Value;                  
00082         int Size;                           
00083         bool Endian;                        
00084         bool IsBatch;                       
00085         TypeRef RefType;                    
00086         const char *RefTarget;              
00087         const char *SymSpace;               
00088     };
00089 
00090     // Forward declare TypeRecord to allow TypeRecordPtr to be defined early
00091     class TypeRecord;
00092 
00094     typedef SmartPtr<TypeRecord> TypeRecordPtr;
00095 
00097     typedef std::list<TypeRecordPtr> TypeRecordList;
00098 
00100     typedef std::list<TypeRecordList> TypeRecordListList;
00101 
00103     class TypeRecord : public RefCount<TypeRecord>
00104     {
00105     public:
00106         TypeClass Class;                    
00107         std::string Type;                   
00108         std::string Detail;                 
00109         std::string Base;                   
00110         ULPtr UL;                           
00111         std::string Value;                  
00112         int Size;                           
00113         bool Endian;                        
00114         bool IsBatch;                       
00115         TypeRef RefType;                    
00116         std::string RefTarget;              
00117         SymbolSpacePtr SymSpace;            
00118         TypeRecordList Children;            
00119 
00120     public:
00122         TypeRecord()
00123         {
00124             Class = TypeNULL;
00125             Size = 0;
00126             Endian = false;
00127             IsBatch = false;
00128             RefType = TypeRefUndefined;
00129         }
00130     };
00131 
00133 
00136     int LoadTypes(char *TypesFile, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols);
00137 
00139 
00144     int LoadTypes(const ConstTypeRecord *TypesData, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols);
00145 
00147 
00151     int LoadTypes(TypeRecordList &TypesData, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols);
00152 
00154 
00156     inline MDTraitsPtr LookupTraits(const char* Name) { return MDTraits::Find(std::string(Name)); }
00157 
00159 
00162     bool DisableBuiltInTraits(void);
00163 
00164 
00165     /* Define macros for static type definitions */
00166 
00168 #define MXFLIB_TYPE_START(Name) const ConstTypeRecord Name[] = {
00169 
00171 #define MXFLIB_TYPE_START_SYM(Name, Sym) const ConstTypeRecord Name[] = { { TypeSymbolSpace, "", "", "", "", "", 0, false, false, TypeRefUndefined, NULL, Sym },
00172 
00174 
00180 #define MXFLIB_TYPE_BASIC(Name, Detail, UL, Size, Endian) { TypeBasic, Name, Detail, "", UL, "", Size, Endian, false, TypeRefUndefined, NULL, NULL },
00181 
00183 
00190 #define MXFLIB_TYPE_BASIC_SYM(Name, Detail, UL, Size, Endian, Sym) { TypeBasic, Name, Detail, "", UL, "", Size, Endian, false, TypeRefUndefined, NULL, Sym },
00191 
00193 
00201 #define MXFLIB_TYPE_BASIC_REF(Name, Detail, UL, Size, Endian, RefType, RefTarget) { TypeBasic, Name, Detail, "", UL, "", Size, Endian, false, RefType, RefTarget, NULL },
00202 
00204 
00213 #define MXFLIB_TYPE_BASIC_REF_SYM(Name, Detail, UL, Size, Endian, RefType, RefTarget, Sym) { TypeBasic, Name, Detail, "", UL, "", Size, Endian, false, RefType, RefTarget, Sym },
00214 
00216 
00222 #define MXFLIB_TYPE_INTERPRETATION(Name, Detail, Base, UL, Size) { TypeInterpretation, Name, Detail, Base, UL, "", Size, false, false, TypeRefUndefined, NULL, NULL },
00223 
00225 
00232 #define MXFLIB_TYPE_INTERPRETATION_SYM(Name, Detail, Base, UL, Size, Sym) { TypeInterpretation, Name, Detail, Base, UL, "", Size, false, false, TypeRefUndefined, NULL, Sym },
00233 
00235 
00243 #define MXFLIB_TYPE_INTERPRETATION_REF(Name, Detail, Base, UL, Size, RefType, RefTarget) { TypeInterpretation, Name, Detail, Base, UL, "", Size, false, false, RefType, RefTarget, NULL },
00244 
00246 
00255 #define MXFLIB_TYPE_INTERPRETATION_REF_SYM(Name, Detail, Base, UL, Size, RefType, RefTarget, Sym) { TypeInterpretation, Name, Detail, Base, UL, "", Size, false, false, RefType, RefTarget, Sym },
00256 
00258 
00265 #define MXFLIB_TYPE_MULTIPLE(Name, Detail, Base, UL, IsBatch, Size) { TypeMultiple, Name, Detail, Base, UL, "", Size, false, IsBatch, TypeRefUndefined, NULL, NULL },
00266 
00268 
00276 #define MXFLIB_TYPE_MULTIPLE_SYM(Name, Detail, Base, UL, IsBatch, Size, Sym) { TypeMultiple, Name, Detail, Base, UL, "", Size, false, IsBatch, TypeRefUndefined, NULL, Sym },
00277 
00279 
00288 #define MXFLIB_TYPE_MULTIPLE_REF(Name, Detail, Base, UL, IsBatch, Size, RefType, RefTarget) { TypeMultiple, Name, Detail, Base, UL, "", Size, false, IsBatch, RefType, RefTarget, NULL },
00289 
00291 
00301 #define MXFLIB_TYPE_MULTIPLE_REF_SYM(Name, Detail, Base, UL, IsBatch, Size, RefType, RefTarget, Sym) { TypeMultiple, Name, Detail, Base, UL, "", Size, false, IsBatch, RefType, RefTarget, Sym },
00302 
00304 
00307 #define MXFLIB_TYPE_COMPOUND(Name, Detail, UL) { TypeCompound, Name, Detail, "", UL, "", 0, false, false, TypeRefUndefined, NULL, NULL },
00308 
00310 
00314 #define MXFLIB_TYPE_COMPOUND_SYM(Name, Detail, UL, Sym) { TypeCompound, Name, Detail, "", UL, "", 0, false, false, TypeRefUndefined, NULL, Sym },
00315 
00317 
00323 #define MXFLIB_TYPE_COMPOUND_ITEM(Name, Detail, Type, UL, Size) { TypeSub, Name, Detail, Type, UL, "", Size, false, false, TypeRefUndefined, NULL, NULL },
00324 
00326 #define MXFLIB_TYPE_COMPOUND_END
00327 
00329 
00333 #define MXFLIB_TYPE_ENUM(Name, Detail, Type, UL) { TypeEnum, Name, Detail, Type, UL, "", 0, false, false, TypeRefUndefined, NULL, NULL },
00334 
00336 
00341 #define MXFLIB_TYPE_ENUM_SYM(Name, Detail, Type, UL, Sym) { TypeEnum, Name, Detail, Type, UL, "", 0, false, false, TypeRefUndefined, NULL, Sym },
00342 
00344 
00348 #define MXFLIB_TYPE_ENUM_VALUE(Name, Detail, Value) { TypeSub, Name, Detail, "", "", Value, 0, false, false, TypeRefUndefined, NULL, NULL },
00349 
00351 
00355 #define MXFLIB_LABEL(Name, Detail, UL) { TypeLabel, Name, Detail, "", UL, NULL, 0, false, false, TypeRefUndefined, NULL, NULL },
00356 
00358 
00363 #define MXFLIB_LABEL_SYM(Name, Detail, UL, Sym) { TypeLabel, Name, Detail, "", UL, NULL, 0, false, false, TypeRefUndefined, NULL, Sym },
00364 
00366 
00371 #define MXFLIB_MASKED_LABEL(Name, Detail, UL, Mask) { TypeLabel, Name, Detail, "", UL, Mask, 0, false, false, TypeRefUndefined, NULL, NULL },
00372 
00374 
00380 #define MXFLIB_MASKED_LABEL_SYM(Name, Detail, UL, Mask, Sym) { TypeLabel, Name, Detail, "", UL, Mask, 0, false, false, TypeRefUndefined, NULL, Sym },
00381 
00382 
00384 #define MXFLIB_TYPE_ENUM_END
00385 
00387 #define MXFLIB_TYPE_END { TypeNULL, "", "", "", "", "", 0, false, false, TypeRefUndefined, NULL, NULL } };
00388 
00389 /* Example usage:
00390     MXFLIB_TYPE_START(TypeArray)
00391         MXFLIB_TYPE_BASIC("UInt8", "Unsigned 8 bit integer", "urn:x-ul:060E2B34.0104.0101.01010100.00000000", 1, false)
00392         MXFLIB_TYPE_BASIC("UInt16", "Unsigned 16 bit integer", "urn:x-ul:060E2B34.0104.0101.01010200.00000000", 2, true)
00393         MXFLIB_TYPE_BASIC("Int32", "32 bit integer", "urn:x-ul:060E2B34.0104.0101.01010700.00000000", 4, true)
00394         
00395         MXFLIB_TYPE_INTERPRETATION("VersionType", "Version number (created from major*256 + minor)", "UInt16", "urn:x-ul:060E2B34.0104.0101.03010300.00000000", 0)
00396         MXFLIB_TYPE_INTERPRETATION("UTF16", "Unicode UTF-16 coded character", "UInt16", "urn:x-ul:060E2B34.0104.0101.01100100.00000000", 0)
00397         MXFLIB_TYPE_INTERPRETATION("Boolean", "Boolean", "UInt8", "urn:x-ul:060E2B34.0104.0101.01040100.00000000", 0)
00398 
00399         MXFLIB_TYPE_MULTIPLE("UTF16String", "Unicode UTF-16 coded string", "UTF16", "urn:x-ul:060E2B34.0104.0101.01100200.00000000", false, 0)
00400         MXFLIB_TYPE_MULTIPLE("Int32Array", "Array of Int32 values", "Int32", "urn:x-ul:060E2B34.0104.0101.04010900.00000000", false, 0)
00401         MXFLIB_TYPE_MULTIPLE("Int32Batch", "Batch of Int32 values", "Int32", "urn:x-ul:060E2B34.0104.0101.04030200.00000000", true, 0)
00402         MXFLIB_TYPE_MULTIPLE("Int32Pair", "Pair of Int32 values", "Int32", "", false, 2)
00403 
00404         MXFLIB_TYPE_COMPOUND("Rational", "Rational", "urn:x-ul:060E2B34.0104.0101.03010100.00000000")
00405             MXFLIB_TYPE_COMPOUND_ITEM("Numerator", "Numerator", "Int32", "urn:x-ul:060E2B34.0104.0101.03010101.00000000", 0)
00406             MXFLIB_TYPE_COMPOUND_ITEM("Denominator", "Denominator", "Int32", "urn:x-ul:060E2B34.0104.0101.03010102.00000000", 0)
00407         MXFLIB_TYPE_COMPOUND_END
00408     MXFLIB_TYPE_END
00409 */
00410 }
00411 
00412 
00413 namespace mxflib
00414 {
00416     enum ClassType
00417     {
00418         ClassNULL = 0,                      
00419         ClassPack,                          
00420         ClassSet,                           
00421         ClassVector,                        
00422         ClassArray,                         
00423         ClassItem,                          
00424         ClassRename,                        
00425         ClassSymbolSpace                    
00426     };
00427 
00429     enum ClassUsage
00430     {
00431         ClassUsageNULL = 0,                 
00432         ClassUsageOptional,                 
00433         ClassUsageDecoderRequired,          
00434         ClassUsageEncoderRequired,          
00435         ClassUsageRequired,                 
00436         ClassUsageBestEffort,               
00437         ClassUsageToxic,                    
00438         ClassUsageDark                      
00439     };
00440 
00442     typedef TypeRef ClassRef;
00443 
00445     const ClassRef ClassRefUndefined = TypeRefUndefined;
00446 
00448     const ClassRef ClassRefNone = TypeRefNone;
00449 
00451     const ClassRef ClassRefStrong = TypeRefStrong;
00452 
00454     const ClassRef ClassRefWeak = TypeRefWeak;
00455 
00457     const ClassRef ClassRefGlobal = TypeRefGlobal;
00458 
00460     const ClassRef ClassRefTarget = TypeRefTarget;
00461 
00462 
00464     struct ConstClassRecord
00465     {
00466         ClassType Class;                    
00467         unsigned int MinSize;               
00468         unsigned int MaxSize;               
00469         const char *Name;                   
00470         const char *Detail;                 
00471         ClassUsage Usage;                   
00472         const char *Base;                   
00473         UInt16 Tag;                         
00474         const char *UL;                     
00475         const char *Default;                
00476         const char *DValue;                 
00477         ClassRef RefType;                   
00478         const char *RefTarget;              
00479         const char *SymSpace;               
00480         bool ExtendSubs;                    
00481     };
00482 
00483     // Forward declare ClassRecord to allow ClassRecordPtr to be defined early
00484     class ClassRecord;
00485 
00487     typedef SmartPtr<ClassRecord> ClassRecordPtr;
00488 
00490     typedef std::list<ClassRecordPtr> ClassRecordList;
00491 
00493     typedef std::list<ClassRecordList> ClassRecordListList;
00494 
00496     class ClassRecord : public RefCount<ClassRecord>
00497     {
00498     public:
00499         ClassType Class;                    
00500         unsigned int MinSize;               
00501         unsigned int MaxSize;               
00502         std::string Name;                   
00503         std::string Detail;                 
00504         ClassUsage Usage;                   
00505         std::string Base;                   
00506         UInt16 Tag;                         
00507         ULPtr UL;                           
00508         bool HasDefault;                    
00509         std::string Default;                
00510         bool HasDValue;                     
00511         std::string DValue;                 
00512         ClassRecordList Children;           
00513         ClassRef RefType;                   
00514         std::string RefTarget;              
00515         SymbolSpacePtr SymSpace;            
00516         bool ExtendSubs;                    
00517     
00518     public:
00520         ClassRecord()
00521         {
00522             Class = ClassNULL;
00523             MinSize = 0;
00524             MaxSize = 0;
00525             Usage = ClassUsageNULL;
00526             Tag = 0;
00527             HasDefault = false;
00528             HasDValue = false;
00529             RefType = ClassRefUndefined;
00530             ExtendSubs = true;
00531         }
00532     };
00533 
00534 
00536 
00539     int LoadClasses(ClassRecordList &ClassesData, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols);
00540 
00542 
00546     int LoadClasses(const ConstClassRecord *ClassData, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols);
00547 
00548 
00549     /* Define macros for static type definitions */
00550 
00552 #define MXFLIB_CLASS_START(Name) const ConstClassRecord Name[] = {
00553 
00555 #define MXFLIB_CLASS_START_SYM(Name, Sym) const ConstClassRecord Name[] = { { ClassSymbolSpace, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", Sym, true },
00556 
00558 
00563 #define MXFLIB_CLASS_SET(Name, Detail, Base, UL) { ClassSet, 2, 2, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", NULL, true },
00564 
00566 
00572 #define MXFLIB_CLASS_SET_SYM(Name, Detail, Base, UL, Sym) { ClassSet, 2, 2, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", Sym, true },
00573 
00575 
00580 #define MXFLIB_CLASS_SET_NOSUB(Name, Detail, Base, UL) { ClassSet, 2, 2, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", NULL, false },
00581 
00583 
00589 #define MXFLIB_CLASS_SET_NOSUB_SYM(Name, Detail, Base, UL, Sym) { ClassSet, 2, 2, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", Sym, false },
00590 
00592 #define MXFLIB_CLASS_SET_END { ClassNULL, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", NULL, true },
00593 
00595 
00600 #define MXFLIB_CLASS_FIXEDPACK(Name, Detail, Base, UL) { ClassPack, 0, 0, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", NULL, true },
00601 
00603 
00609 #define MXFLIB_CLASS_FIXEDPACK_SYM(Name, Detail, Base, UL, Sym) { ClassPack, 0, 0, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", Sym, true },
00610 
00612 
00617 #define MXFLIB_CLASS_FIXEDPACK_NOSUB(Name, Detail, Base, UL) { ClassPack, 0, 0, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", NULL, false },
00618 
00620 
00626 #define MXFLIB_CLASS_FIXEDPACK_NOSUB_SYM(Name, Detail, Base, UL, Sym) { ClassPack, 0, 0, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", Sym, false },
00627 
00629 #define MXFLIB_CLASS_FIXEDPACK_END { ClassNULL, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", NULL, true },
00630 
00632 
00641 #define MXFLIB_CLASS_ITEM(Name, Detail, Usage, Type, MinSize, MaxSize, Tag, UL, Default, DValue) { ClassItem, MinSize, MaxSize, Name, Detail, Usage, Type, Tag, UL, Default, DValue, ClassRefUndefined, "", NULL, true },
00642 
00644 
00655 #define MXFLIB_CLASS_ITEM_REF(Name, Detail, Usage, Type, MinSize, MaxSize, Tag, UL, RefType, RefTarget, Default, DValue) { ClassItem, MinSize, MaxSize, Name, Detail, Usage, Type, Tag, UL, Default, DValue, RefType, RefTarget, NULL, true },
00656 
00658 
00668 #define MXFLIB_CLASS_ITEM_SYM(Name, Detail, Usage, Type, MinSize, MaxSize, Tag, UL, Default, DValue, Sym) { ClassItem, MinSize, MaxSize, Name, Detail, Usage, Type, Tag, UL, Default, DValue, ClassRefUndefined, "", Sym, true },
00669 
00671 
00683 #define MXFLIB_CLASS_ITEM_REF_SYM(Name, Detail, Usage, Type, MinSize, MaxSize, Tag, UL, RefType, RefTarget, Default, DValue, Sym) { ClassItem, MinSize, MaxSize, Name, Detail, Usage, Type, Tag, UL, Default, DValue, RefType, RefTarget, Sym, true },
00684 
00686 
00692 #define MXFLIB_CLASS_VECTOR(Name, Detail, Usage, Tag, UL) { ClassVector, 0, 0, Name, Detail, Usage, "", Tag, UL, NULL, NULL, ClassRefUndefined, "", NULL, true },
00693 
00695 
00703 #define MXFLIB_CLASS_VECTOR_REF(Name, Detail, Usage, Tag, UL, RefType, RefTarget) { ClassVector, 0, 0, Name, Detail, Usage, "", Tag, UL, NULL, NULL, RefType, RefTarget, NULL, true },
00704 
00706 #define MXFLIB_CLASS_VECTOR_END { ClassNULL, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", NULL, true },
00707 
00709 
00715 #define MXFLIB_CLASS_ARRAY(Name, Detail, Usage, Tag, UL) { ClassArray, 0, 0, Name, Detail, Usage, "", Tag, UL, NULL, NULL, ClassRefUndefined, "", NULL, true },
00716 
00718 
00724 #define MXFLIB_CLASS_ARRAY_REF(Name, Detail, Usage, Tag, UL, RefType, RefTarget) { ClassArray, 0, 0, Name, Detail, Usage, "", Tag, UL, NULL, NULL, RefType, RefTarget, NULL, true },
00725 
00727 #define MXFLIB_CLASS_ARRAY_END { ClassNULL, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", NULL, true },
00728 
00730 
00735 #define MXFLIB_CLASS_RENAME(Name, Detail, Base, UL) { ClassRename, 0, 0, Name, Detail, ClassUsageNULL, Base, 0, UL, NULL, NULL, ClassRefUndefined, "", NULL, true },
00736 
00738 #define MXFLIB_CLASS_END { ClassNULL, 0, 0, "", "", ClassUsageNULL, "", 0, "", NULL, NULL, ClassRefUndefined, "", NULL, true } };
00739 
00740 
00741 /* Example usage:
00742     MXFLIB_CLASS_RENAME("KLVFill", "KLV Filler packet", "RAW", "06 0E 2B 34 01 01 01 01 03 01 02 10 01 00 00 00")
00743     MXFLIB_CLASS_FIXEDPACK("PartitionMetadata", "Identifies a Partition Pack", "")
00744         MXFLIB_CLASS_ITEM("MajorVersion", "Major Version number of MXF byte-level format (non-backwards compatible version number)", ClassUsageRequired, "UInt16", 2, 2, "06 0e 2b 34 01 01 01 04  03 01 02 01 06 00 00 00", "", "0001", "")
00745         MXFLIB_CLASS_ITEM("MinorVersion", "Minor Version number of MXF byte-level format (backwards compatible version number)", ClassUsageRequired, "UInt16", 2, 2, "06 0e 2b 34 01 01 01 04  03 01 02 01 06 00 00 00", "", "0001", "")
00746 ...
00747         MXFLIB_CLASS_ITEM_REF("PrimaryPackage", "The primary Package in this file", ClassUsageOptional, "UUID", 16, 16, "06 0e 2b 34 01 01 01 04  06 01 01 04 01 08 00 00", "3b 08", "", "", RefWeak, "GenericPackage")
00748 ...
00749         MXFLIB_CLASS_VECTOR("EssenceContainers", "The unordered batch of Universal Labels of Essence Containers used in or referenced by this file", ClassUsageRequired, "06 0e 2b 34 01 01 01 05  01 02 02 10 02 01 00 00", "", "")
00750             MXFLIB_CLASS_ITEM("EssenceContainer", "Universal Labels of Essence Container", ClassUsageRequired, "Label", 16, 16, "", "", "", "")
00751         MXFLIB_CLASS_VECTOR_END
00752     MXFLIB_CLASS_END
00753 
00754     MXFLIB_CLASS_RENAME("OpenHeader", "Open Header Partition Pack", "PartitionMetadata", "06 0e 2b 34 02 05 01 01  0d 01 02 01 01 02 01 00")
00755     MXFLIB_CLASS_RENAME("OpenCompleteHeader", "Open Complete Header Partition Pack", "PartitionMetadata", "06 0e 2b 34 02 05 01 01  0d 01 02 01 01 02 03 00")
00756 
00757  <PrimaryPackage detail="The primary Package in this file" use="optional" type="UUID" minLength="16" maxLength="16" key="3b 08" globalKey="06 0e 2b 34 01 01 01 04  06 01 01 04 01 08 00 00" ref="weak" target="GenericPackage"/>
00758 */
00759 }
00760 
00761 
00762 namespace mxflib
00763 {
00765     enum DictionaryType
00766     {
00767         DictionaryNULL = 0,                 
00768         DictionaryTypes,                    
00769         DictionaryClasses                   
00770     };
00771 
00773     struct ConstDictionaryRecord
00774     {
00775         DictionaryType Type;                
00776         const void *Dict;                   
00777     };
00778 
00779     // Forward declare Dictionary to allow DictionaryPtr to be defined early
00780     class Dictionary;
00781 
00783     typedef SmartPtr<Dictionary> DictionaryPtr;
00784 
00786     typedef std::list<DictionaryPtr> DictionaryList;
00787 
00789     class Dictionary : public RefCount<Dictionary>
00790     {
00791     public:
00792         TypeRecordListList Types;           
00793         ClassRecordListList Classes;        
00794     };
00795 
00796 
00798 
00801     int LoadDictionary(DictionaryPtr &DictionaryData, SymbolSpacePtr DefaultSymbolSpace, bool FastFail = false);
00802 
00804 
00807     inline int LoadDictionary(DictionaryPtr &DictionaryData, bool FastFail = false, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00808     {
00809         return LoadDictionary(DictionaryData, DefaultSymbolSpace, FastFail );
00810     }
00811 
00813 
00817     int LoadDictionary(const ConstDictionaryRecord *DictionaryData, SymbolSpacePtr DefaultSymbolSpace, bool FastFail = false);
00818 
00820 
00824     inline int LoadDictionary(const ConstDictionaryRecord *DictionaryData, bool FastFail = false, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00825     {
00826         return LoadDictionary(DictionaryData, DefaultSymbolSpace, FastFail);
00827     }
00828 
00830 
00833     int LoadDictionary(const char *DictFile, SymbolSpacePtr DefaultSymbolSpace, bool FastFail = false);
00834 
00836 
00839     inline int LoadDictionary(std::string DictFile, SymbolSpacePtr DefaultSymbolSpace, bool FastFail = false)
00840     {
00841         return LoadDictionary(DictFile.c_str(), DefaultSymbolSpace, FastFail );
00842     }
00843 
00845 
00848     inline int LoadDictionary(const char *DictFile, bool FastFail = false, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00849     {
00850         return LoadDictionary(DictFile, DefaultSymbolSpace, FastFail );
00851     }
00852 
00854 
00857     inline int LoadDictionary(std::string DictFile, bool FastFail = false, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00858     {
00859         return LoadDictionary(DictFile.c_str(), DefaultSymbolSpace, FastFail );
00860     }
00861 
00862 
00864 #define MXFLIB_DICTIONARY_START(Name)       const ConstDictionaryRecord Name[] = {
00865 
00867 #define MXFLIB_DICTIONARY_TYPES(Types)      { DictionaryTypes, Types },
00868 
00870 #define MXFLIB_DICTIONARY_CLASSES(Classes)  { DictionaryClasses, Classes },
00871 
00873 #define MXFLIB_DICTIONARY_END               { DictionaryNULL, NULL } };
00874 
00875 /* Example usage:
00876     MXFLIB_DICTIONARY_START(Dict)
00877         MXFLIB_DICTIONARY_TYPES(MyTypes)
00878         MXFLIB_DICTIONARY_CLASSES(MyClasses)
00879     MXFLIB_DICTIONARY_END
00880 */
00881 }
00882 
00883 namespace mxflib
00884 {
00885     class Label;
00886 
00887     // A Smart pointer to a Label
00888     typedef SmartPtr<Label> LabelPtr;
00889 
00891     class Label : public RefCount<Label>
00892     {
00893     protected:
00894         UL Value;                                       
00895         UInt8 Mask[16];                                 
00896         bool NonZeroMask;                               
00897         std::string Name;                               
00898         std::string Detail;                             
00899 
00900     protected:
00902         typedef std::map<UL, LabelPtr> LabelULMap;
00903 
00905         typedef std::multimap<UL, LabelPtr> LabelULMultiMap;
00906 
00908         static LabelULMap LabelMap;
00909 
00911         static LabelULMultiMap LabelMultiMap;
00912 
00913     protected:
00914         // Private constructor - to build a new label one of the Insert() functions must be called
00915         Label(std::string LabelName, std::string Detail, const UInt8 *LabelUL, const UInt8 *LabelMask) 
00916             : Value(LabelUL), Detail(Detail)
00917         {
00918             Init(LabelName, LabelMask);
00919         }
00920 
00921         // Private constructor - to build a new label one of the Insert() functions must be called
00922         Label(std::string LabelName, std::string Detail, const UUID &LabelULasUUID, const UInt8 *LabelMask) 
00923             : Value(LabelULasUUID), Detail(Detail)
00924         {
00925             Init(LabelName, LabelMask);
00926         }
00927 
00928         // Constructor common part - called by constructors
00929         void Init(std::string LabelName, const UInt8 *LabelMask)
00930         {
00931             Name = LabelName;
00932 
00933             if(LabelMask)
00934             {
00935                 memcpy(Mask, LabelMask, 16);
00936                 NonZeroMask = true;
00937             }
00938             else
00939             {
00940                 memset(Mask, 0, 16);
00941                 NonZeroMask = false;
00942             }
00943         }
00944 
00945     public:
00947         std::string GetName(void) { return Name; };
00948 
00950         std::string GetDetail(void) { return Detail; };
00951 
00953         bool HasMask(void) { return NonZeroMask; }
00954 
00955     public:
00957 
00959         static bool Insert(std::string Name, std::string Detail, const UInt8 *LabelValue, const UInt8 *LabelMask = NULL);
00960 
00962 
00964         static bool Insert(std::string Name, std::string Detail, const ULPtr &LabelValue, const UInt8 *LabelMask = NULL);
00965 
00967 
00969         static bool Insert(std::string Name, std::string Detail, const UL &LabelValue, const UInt8 *LabelMask = NULL);
00970 
00972 
00974         static bool Insert(std::string Name, std::string Detail, const UUIDPtr &LabelValue, const UInt8 *LabelMask = NULL);
00975 
00977 
00979         static bool Insert(std::string Name, std::string Detail, const mxflib::UUID &LabelValue, const UInt8 *LabelMask = NULL);
00980 
00981     public:
00983         static LabelPtr Find(const UL &LabelValue);
00984 
00986         static LabelPtr Find(const ULPtr &LabelValue)
00987         {
00988             return Find(*LabelValue);
00989         }
00990 
00992         static LabelPtr Find(const UInt8 *LabelValue)
00993         {
00994             /* Make a value UL and use that in the main search */
00995             UL ValueUL(LabelValue);
00996             return Find(ValueUL);
00997         }
00998     };
00999 }
01000 
01001 #endif // MXFLIB__DICTIONARY_H
01002 

Generated on Mon Apr 2 15:20:51 2007 for MXFLib by  doxygen 1.5.1-p1