mdobject.h

Go to the documentation of this file.
00001 
00013 /*
00014  *  Copyright (c) 2004, Matt Beard
00015  *  Portions copyright (c) 2002, BBC R&D
00016  *
00017  *  This software is provided 'as-is', without any express or implied warranty.
00018  *  In no event will the authors be held liable for any damages arising from
00019  *  the use of this software.
00020  *
00021  *  Permission is granted to anyone to use this software for any purpose,
00022  *  including commercial applications, and to alter it and redistribute it
00023  *  freely, subject to the following restrictions:
00024  *
00025  *    1. The origin of this software must not be misrepresented; you must
00026  *       not claim that you wrote the original software. If you use this
00027  *       software in a product, an acknowledgment in the product
00028  *       documentation would be appreciated but is not required.
00029  *  
00030  *    2. Altered source versions must be plainly marked as such, and must
00031  *       not be misrepresented as being the original software.
00032  *  
00033  *    3. This notice may not be removed or altered from any source
00034  *       distribution.
00035  */
00036 #ifndef MXFLIB__MDOBJECT_H
00037 #define MXFLIB__MDOBJECT_H
00038 
00039 
00040 // STL Includes
00041 #include <string>
00042 #include <list>
00043 #include <map>
00044 
00045 
00046 // mxflib includes
00047 #include <mxflib/primer.h>
00048 
00049 
00050 namespace mxflib
00051 {
00053     class SymbolSpace : public std::map<std::string, ULPtr>, public RefCount<SymbolSpace>
00054     {
00055     protected:
00056         static SymbolSpaceMap AllSymbolSpaces;                  
00057 
00058         std::string SymName;                                    
00059 
00060     private:
00062         SymbolSpace(const SymbolSpace &rhs);
00063 
00064     public:
00066         SymbolSpace(std::string Name) : SymName(Name)
00067         {
00068             SymbolSpaceMap::iterator it = AllSymbolSpaces.find(Name);
00069 
00070             if(it != AllSymbolSpaces.end())
00071             {
00072                 error("Duplicate symbol space name \"%s\"\n");
00073             }
00074 
00075             AllSymbolSpaces.insert(SymbolSpaceMap::value_type(Name, this));
00076         };
00077 
00078 
00080 
00082         bool AddSymbol(std::string Symbol, ULPtr &UL)
00083         {
00084             iterator it = find(Symbol);
00085             if(it != end()) return false;
00086 
00087             insert(value_type(Symbol, UL));
00088 
00089             return true;
00090         }
00091 
00092 
00094         ULPtr Find(std::string Symbol, bool SearchAll = false)
00095         {
00096             iterator it = find(Symbol);
00097 
00098             if(it != end()) return (*it).second;
00099 
00100             if(SearchAll)
00101             {
00102                 SymbolSpaceMap::iterator map_it = AllSymbolSpaces.begin();
00103                 while(map_it != AllSymbolSpaces.end())
00104                 {
00105                     it = (*map_it).second->find(Symbol);
00106                     if(it != end()) return (*it).second;
00107 
00108                     map_it++;
00109                 }
00110             }
00111 
00112             return NULL;
00113         }
00114 
00116         static SymbolSpacePtr FindSymbolSpace(std::string Name)
00117         {
00118             SymbolSpaceMap::iterator it = AllSymbolSpaces.find(Name);
00119 
00120             if(it != AllSymbolSpaces.end()) return (*it).second;
00121 
00122             return NULL;
00123         }
00124 
00126         const std::string &Name(void) const { return SymName; }
00127     };
00128 }
00129 
00130 
00131 namespace mxflib
00132 {
00133     // Forward declare so the class can include pointers to itself
00134     class MDOType;
00135 
00137     typedef SmartPtr<MDOType> MDOTypePtr;
00138 
00140     typedef ParentPtr<MDOType> MDOTypeParent;
00141 
00143     typedef std::list<MDOTypePtr> MDOTypeList;
00144 
00146     typedef std::map<std::string, MDOTypePtr> MDOTypeMap;
00147 
00148     // Forward declare the ObjectInterface
00149     class ObjectInterface;
00150 }
00151 
00152 
00153 
00154 namespace mxflib
00155 {
00156 #define MXFLIB_MAXDICTDEPTH 32
00157 
00159     typedef ClassUsage DictUse;
00160 
00162     const ClassUsage DICT_USE_NONE = ClassUsageNULL;
00163     
00165     const ClassUsage DICT_USE_REQUIRED = ClassUsageRequired;
00166     
00168     const ClassUsage DICT_USE_ENCODER_REQUIRED = ClassUsageEncoderRequired;
00169     
00171     const ClassUsage DICT_USE_DECODER_REQUIRED = ClassUsageDecoderRequired;
00172     
00174     const ClassUsage DICT_USE_OPTIONAL = ClassUsageOptional;
00175     
00177     const ClassUsage DICT_USE_DARK = ClassUsageDark;
00178     
00180     const ClassUsage DICT_USE_TOXIC = ClassUsageToxic;
00181 
00183     const ClassUsage DICT_USE_BEST_EFFORT = ClassUsageBestEffort;
00184 
00185     /*
00186     ** Enumeration type for key formats
00187     */
00188     typedef enum
00189     {
00190         DICT_KEY_NONE = 0,
00191         DICT_KEY_1_BYTE = 1,
00192         DICT_KEY_2_BYTE = 2,
00193         DICT_KEY_4_BYTE = 4,
00194         DICT_KEY_AUTO = 3
00195     } DictKeyFormat;
00196 
00197 
00198     /*
00199     ** Enumeration type for length formats
00200     */
00201     typedef enum
00202     {
00203         DICT_LEN_NONE = 0,
00204         DICT_LEN_1_BYTE = 1,
00205         DICT_LEN_2_BYTE = 2,
00206         DICT_LEN_4_BYTE = 4,
00207         DICT_LEN_BER = 3
00208     } DictLenFormat;
00209 
00210 
00212     typedef ClassRef DictRefType;
00213 
00215     const ClassRef DICT_REF_NONE = ClassRefNone;
00216 
00218     const ClassRef DICT_REF_STRONG = ClassRefStrong;
00219 
00221     const ClassRef DICT_REF_WEAK = ClassRefWeak;
00222 
00224     const ClassRef DICT_REF_TARGET = ClassRefTarget;
00225 
00226 
00227 /* Notes about the structure of dictionaries...
00228    ============================================
00229 
00230    The dictionary is held as a list of MDOType objects, each of 
00231    which holds information about a 'type' held in the dictionary.
00232 
00233    The dictionary is generally tree structured, with some types
00234    being children of others (this matches the sets with child items
00235    of an MXF file) When an item is a child it contains a pointer to
00236    its parent.  Each parent item contain pointers to each child item
00237    through derivation from MDOTypeMap (maps child name to pointer to
00238    child item). Care should be taken iterating this map as the
00239    order is likely to be alphabetical rather than dictionary order
00240    so where dictionary order is important (such as packs) iterate
00241    through the ChildList property.
00242 
00243    Inheritance is supported where a type is regarded as a modified
00244    version of another (base) type. The mechanism for inheritance is
00245    that a derived MDOType will be a copy of the base MDOType
00246    with a link back to the base in 'Base'. The 'Children' lists is
00247    copied and new child types are added to these lists.
00248    If a child of a derived type has the same name as a child of
00249    the base it is regarded as a replacement. 
00250 */
00251 }
00252 
00253 
00254 namespace mxflib
00255 {
00257     class MDOType : public RefCount<MDOType>, public MDOTypeMap
00258     {
00259     protected:
00260         MDContainerType ContainerType;
00261 
00262         std::string RootName;           
00263 
00264     protected:
00265         MDTypePtr ValueType;            
00266 
00267     public:
00268         MDOTypeParent Base;             
00269 
00270     protected:
00271         StringList ChildOrder;          
00272         MDOTypeList ChildList;          
00273         MDOTypeParent Parent;           
00274         ULPtr TypeUL;                   
00275 
00276         /* Dictionary data */
00277         DataChunk       Key;            
00278         DataChunk       GlobalKey;      
00279         std::string     DictName;       
00280         std::string     Detail;         
00281         std::string     TypeName;       
00282         DictKeyFormat   KeyFormat;      
00283         DictLenFormat   LenFormat;      
00284         unsigned int    minLength;      
00285         unsigned int    maxLength;      
00286         DictUse         Use;            
00287         DataChunk       Default;        
00288         DataChunk       DValue;         
00289         ClassRef        RefType;        
00290         MDOTypeParent   RefTarget;      
00291         std::string     RefTargetName;  
00292 
00296 
00297         MDOType();
00298 
00299     public:
00301         MDOType(MDContainerType ContainerType, std::string RootName, std::string Name, std::string Detail, MDTypePtr Type, 
00302                 DictKeyFormat KeyFormat, DictLenFormat LenFormat, unsigned int minLen, unsigned int maxLen, DictUse Use)
00303             : ContainerType(ContainerType), RootName(RootName), ValueType(Type), DictName(Name), Detail(Detail),
00304               KeyFormat(KeyFormat), LenFormat(LenFormat), minLength(minLen), maxLength(maxLen), Use(Use)
00305         {
00306             // MaxLength = 0 is used for maxlength = unbounded
00307             if(maxLength == 0) maxLength = (unsigned int)-1;
00308 
00309             if(Type) TypeName = Type->Name();
00310             else TypeName = Name;
00311 
00312             // Set the name lookup - UL lookup set when key set
00313             NameLookup[RootName + Name] = this;
00314 
00315             // Start of with no referencing details
00316             RefType = ClassRefNone;
00317         };
00318 
00320         void SetRef(ClassRef Type, ULPtr &Target, std::string TargetName = "")
00321         {
00322             ASSERT(Target);
00323 
00324             RefType = Type;
00325             RefTarget = Find(Target);
00326 
00327             if(!RefTarget)
00328             {
00329                 error("Unknown type UL:%s in MDOType::SetRef()\n", Target->GetString().c_str());
00330                 return;
00331             }
00332             
00333             if(TargetName != "") RefTargetName = TargetName;
00334             else RefTargetName = RefTarget->Name();
00335         }
00336 
00338         void SetRef(ClassRef Type, MDOTypePtr Target, std::string TargetName = "")
00339         {
00340             RefType = Type;
00341             RefTarget = Target;
00342             
00343             if(TargetName != "") RefTargetName = TargetName;
00344             else RefTargetName = Target->Name();
00345         }
00346 
00348         void Derive(MDOTypePtr &BaseEntry);
00349 
00351 
00353         void ReDerive(MDOTypePtr &BaseEntry);
00354 
00356         const MDContainerType &GetContainerType(void) const { return (const MDContainerType &)ContainerType; };
00357 
00359         ClassRef GetRefType(void) const { return RefType; };
00360 
00362         MDOTypePtr GetRefTarget(void) const { return RefTarget; };
00363 
00365 
00368         std::string GetRefTargetName(void) const { return RefTargetName; };
00369 
00371         std::string Name(void) const
00372         {
00373             return DictName;
00374         }
00375 
00377         std::string FullName(void) const
00378         {
00379             return RootName + DictName;
00380         }
00381 
00383         const DataChunk &GetDefault(void) const { return Default; }
00384 
00386         const DataChunk &GetDValue(void) const { return DValue; }
00387 
00389         const ULPtr &GetTypeUL(void) const { return TypeUL; }
00390 
00392         unsigned int GetMinLength(void) const { return minLength; }
00393 
00395         unsigned int GetMaxLength(void) const { return maxLength; }
00396 
00398         const MDTypePtr &GetValueType(void) const { return ValueType; }
00399 
00401 
00403         const StringList &GetChildOrder(void) const { return ChildOrder; }
00404 
00406         const MDOTypeList &GetChildList(void) const { return ChildList; }
00407 
00409         MDOTypePtr Child(std::string Name)
00410         {
00411             MDOTypeMap::iterator it = find(Name);
00412             if(it != end()) return (*it).second;
00413             return NULL;
00414         }
00415 
00417         MDOTypePtr Child(ULPtr &ChildType)
00418         {
00419             MDOTypeMap::iterator it = begin();
00420             while(it != end()) 
00421             { 
00422                 if(((*it).second->TypeUL) && (*((*it).second->TypeUL) == *ChildType)) return (*it).second; 
00423                 it++;
00424             }
00425             return NULL;
00426         }
00427 
00429         const DictKeyFormat &GetKeyFormat(void) const { return KeyFormat; }
00430 
00432         const DictLenFormat &GetLenFormat(void) const { return LenFormat; }
00433 
00435         std::pair<iterator, bool> insert(MDOTypePtr NewType) 
00436         { 
00437             std::string NewName = NewType->Name();
00438             std::pair<iterator, bool> Ret = MDOTypeMap::insert(MDOTypeMap::value_type(NewName, NewType));
00439             ChildList.push_back(NewType);
00440             ChildOrder.push_back(NewName);
00441             return Ret;
00442         }
00443 
00445         ULPtr &GetUL(void) { return TypeUL; }
00446 
00448         const DataChunk &GetKey(void) { return Key; }
00449 
00451         const DataChunk &GetGlobalKey(void) { return GlobalKey; }
00452 
00454         ClassUsage GetUse(void) { return (ClassUsage)Use; }
00455 
00457         bool IsA(std::string BaseType);
00458 
00460         bool IsA(MDOTypePtr &BaseType);
00461         
00463         bool IsA(const UL &BaseType);
00464 
00466         bool IsA(ULPtr &BaseType) { return IsA(*BaseType); }
00467 
00469         void ReDefine(std::string NewDetail, std::string NewBase, unsigned int NewMinSize, unsigned int NewMaxSize);
00470         
00472         void ReDefine(std::string NewDetail)
00473         {
00474             if(NewDetail.length()) Detail = NewDetail;
00475         }
00476 
00477     //** Static Dictionary Handling data and functions **
00478     //***************************************************
00479     protected:
00480         static MDOTypeList  AllTypes;   
00481         static MDOTypeList  TopTypes;   
00482 
00484         static std::map<UL, MDOTypePtr> ULLookup;
00485         
00487         static std::map<UL, MDOTypePtr> ULLookupVer1;
00488 
00490         static MDOTypeMap NameLookup;
00491 
00492     public:
00494 
00499         enum DictionaryItems
00500         {
00501             DICT_ITEM_USE = 1,
00502             DICT_ITEM_REFTYPE = 2,
00503             DICT_ITEM_CONTAINERTYPE = 4,
00504             DICT_ITEM_MINLENGTH = 8,
00505             DICT_ITEM_MAXLENGTH = 16,
00506             DICT_ITEM_KEYFORMAT = 32,
00507             DICT_ITEM_LENFORMAT = 64,
00508             DICT_ITEM_DVALUE = 128
00509         };
00510 
00511     protected:
00513         static PrimerPtr StaticPrimer;
00514 
00515     public:
00517         static void LoadDict(const char *DictFile, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00518         {
00519             LoadDictionary(DictFile, DefaultSymbolSpace);
00520         }
00521 
00523         static void LocateRefTypes(void);
00524 
00526         static PrimerPtr MakePrimer(bool SetStatic = false);
00527         
00529         static PrimerPtr GetStaticPrimer(void) 
00530         { 
00531             if( !StaticPrimer) MakePrimer(true); 
00532             return StaticPrimer;
00533         }
00534 
00536         static MDOTypePtr Find(std::string BaseType, bool SearchAll = false) { return Find(BaseType, MXFLibSymbols, SearchAll); }
00537         
00539         static MDOTypePtr Find(std::string BaseType, SymbolSpacePtr &SymSpace, bool SearchAll = false);
00540 
00541         static MDOTypePtr Find(const UL& BaseUL);
00542         static MDOTypePtr Find(Tag BaseTag, PrimerPtr BasePrimer);
00543 
00544         static MDOTypePtr DefineClass(ClassRecordPtr &ThisClass, SymbolSpacePtr DefaultSymbolSpace, MDOTypePtr Parent = NULL);
00545 
00546         static MDOTypePtr DefineClass(ClassRecordPtr &ThisClass, MDOTypePtr Parent = NULL, SymbolSpacePtr DefaultSymbolSpace = MXFLibSymbols)
00547         {
00548             return DefineClass(ThisClass, DefaultSymbolSpace, Parent);
00549         }
00550 
00551     protected:
00552         static void XML_startElement(void *user_data, const char *name, const char **attrs);
00553         static void XML_endElement(void *user_data, const char *name);
00554         static void XML_warning(void *user_data, const char *msg, ...);
00555         static void XML_error(void *user_data, const char *msg, ...);
00556         static void XML_fatalError(void *user_data, const char *msg, ...);
00557     };
00558 }
00559 
00560 
00561 namespace mxflib
00562 {
00563     // Forward declare so the class can include pointers to itself
00564     class MDObject;
00565     class MDObjectPtr;
00566     class MDObjectParent;
00567 
00569     class MDObjectPtr : public SmartPtr<MDObject>
00570     {
00571     public:
00572         MDObjectPtr() : SmartPtr<MDObject>() {};
00573 //      MDObjectPtr(MDObject * ptr) : SmartPtr<MDObject>(ptr) {};
00574         MDObjectPtr(IRefCount<MDObject> * ptr) : SmartPtr<MDObject>(ptr) {};
00575 
00577         MDObjectPtr operator[](const char *ChildName);
00578         MDObjectPtr operator[](MDOTypePtr &ChildType);
00579         MDObjectPtr operator[](const UL &ChildType);
00580         MDObjectPtr operator[](ULPtr &ChildType);
00581     };
00582 
00584     class MDObjectParent : public ParentPtr<MDObject>
00585     {
00586     public:
00587         MDObjectParent() : ParentPtr<MDObject>() {};
00588         MDObjectParent(IRefCount<MDObject> * ptr) : ParentPtr<MDObject>(ptr) {};
00589 
00591 
00592         void operator=(const MDObjectPtr &sp) { SmartPtr<MDObject>::operator=(sp); }
00593 
00595 
00596         void operator=(RefCount<MDObject> *Ptr) { SmartPtr<MDObject>::operator=(Ptr); }
00597 
00599         MDObjectPtr operator[](const char *ChildName);
00600         MDObjectPtr operator[](MDOTypePtr &ChildType);
00601         MDObjectPtr operator[](const UL &ChildType);
00602         MDObjectPtr operator[](ULPtr &ChildType);
00603     };
00604 
00606     class MDObjectList : public RefCount<MDObjectList>, public std::list<MDObjectPtr> {};
00607     typedef SmartPtr<MDObjectList> MDObjectListPtr;
00608 
00610     typedef std::pair<std::string,MDObjectPtr> MDObjectNamedListItem;
00611     typedef std::list<MDObjectNamedListItem> MDObjectNamedList;
00612 
00614     typedef std::pair<UL,MDObjectPtr> MDObjectULListItem;
00615     typedef std::list<MDObjectULListItem> MDObjectULList;
00616 }
00617 
00618 
00619 namespace mxflib
00620 {
00622     class MDObject : public RefCount<MDObject>, public MDObjectULList
00623     {
00624     protected:
00625         MDOTypePtr Type;
00626 
00627         MDObjectPtr Link;
00628 
00629         bool IsConstructed;             
00630         UInt64 ParentOffset;            
00631         UInt32 KLSize;                  
00632         MDObjectParent Parent;          
00633         MXFFileParent ParentFile;       
00634         ULPtr TheUL;                    
00635         Tag TheTag;                     
00636 
00637         std::string ObjectName;         
00638 
00639         bool Modified;                  
00640 
00642         ObjectInterface *Outer;         
00643 
00644     public:
00646         typedef std::string (*ULTranslator)(ULPtr,const Tag *);
00647 
00648     protected:
00650         static ULTranslator UL2NameFunc;
00651 
00653         static bool ParseDark;
00654 
00655     public:
00656         MDValuePtr Value;
00657 
00658     protected:
00660 
00665         void ULCtor(void);
00666 
00667     public:
00669 
00671         MDObject(std::string BaseType, SymbolSpacePtr &SymSpace = MXFLibSymbols );
00672 
00674         MDObject(MDOTypePtr BaseType);
00675 
00677         MDObject(const UL &BaseUL) { TheUL = new UL(BaseUL); ULCtor(); }
00678 
00680         MDObject(const ULPtr &BaseUL) { TheUL = BaseUL; ULCtor(); }
00681 
00683         MDObject(Tag BaseTag, PrimerPtr BasePrimer);
00684 
00686         void Init(void);
00687 
00689         ~MDObject();
00690 
00692 
00694         MDObjectPtr AddChild(std::string ChildName, bool Replace) { return AddChild(ChildName, MXFLibSymbols, Replace); }
00695 
00697 
00699         MDObjectPtr AddChild(std::string ChildName, SymbolSpacePtr &SymSpace = MXFLibSymbols, bool Replace = true);
00700 
00701     
00703         MDObjectPtr AddChild(MDOTypePtr ChildType, bool Replace = true);
00704         
00706 
00712         MDObjectPtr AddChild(void);
00713 
00715         MDObjectPtr AddChild(const UL &ChildType, bool Replace = true);
00716         
00718         MDObjectPtr AddChild(ULPtr &ChildType, bool Replace = true) { return AddChild(*ChildType, Replace); }
00719 
00721         MDObjectPtr AddChild(MDObjectPtr &ChildObject, bool Replace = false);
00722 
00723     protected:
00725 
00727         MDObjectPtr AddChildInternal(MDObjectPtr ChildObject, bool Replace = false);
00728 
00729     public:
00730 
00732         void RemoveChild(std::string ChildName);
00733 
00735         void RemoveChild(MDOTypePtr &ChildType);
00736 
00738         void RemoveChild(ULPtr &ChildType);
00739 
00741         void RemoveChild(MDObjectPtr ChildObject);
00742 
00744         MDObjectPtr operator[](std::string ChildName);
00745         MDObjectPtr Child(std::string ChildName) { return operator[](ChildName); };
00746         MDObjectListPtr ChildList(std::string ChildName);
00747         MDObjectListPtr ChildList(const UL &ChildType);
00748         MDObjectListPtr ChildList(const ULPtr &ChildType) { return ChildList(*ChildType); };
00749         MDObjectPtr operator[](MDOTypePtr ChildType);
00750         MDObjectPtr Child(MDOTypePtr ChildType) { return operator[](ChildType); };
00751         MDObjectListPtr ChildList(MDOTypePtr ChildType);
00752         MDObjectPtr operator[](const UL &ChildType);
00753         MDObjectPtr operator[](ULPtr &ChildType) { return operator[](*ChildType); };
00754         MDObjectPtr Child(const UL &ChildType) { return operator[](ChildType); };
00755         MDObjectPtr Child(ULPtr &ChildType) { return operator[](*ChildType); };
00756         MDObjectListPtr ChildList(ULPtr &ChildType);
00757 
00758         void SetInt(Int32 Val) { SetModified(true); if (Value) Value->SetInt(Val); };
00759         void SetInt64(Int64 Val) { SetModified(true); if (Value) Value->SetInt64(Val); };
00760         void SetUInt(UInt32 Val) { SetModified(true); if (Value) Value->SetUInt(Val); };
00761         void SetUInt64(UInt64 Val) { SetModified(true); if (Value) Value->SetUInt64(Val); };
00762         void SetUint(UInt32 Val) { SetUInt(Val); }
00763         void SetUint64(UInt64 Val) { SetUInt64(Val); }
00764         void SetString(std::string Val) { SetModified(true); if (Value) Value->SetString(Val); };
00765         bool SetDValue(void);
00766         void SetValue(const DataChunk &Source) { ReadValue(Source); }
00767         void SetValue(MDObjectPtr Source) { ReadValue(Source->Value->PutData()); }
00768         Int32 GetInt(Int32 Default = 0) { if (Value) return Value->GetInt(); else return Default; };
00769         Int64 GetInt64(Int64 Default = 0) { if (Value) return Value->GetInt64(); else return Default; };
00770         UInt32 GetUInt(UInt32 Default = 0) { if (Value) return Value->GetUInt(); else return Default; };
00771         UInt64 GetUInt64(UInt64 Default = 0) { if(Value) return Value->GetUInt64(); else return Default; };
00772         UInt32 GetUint(UInt32 Default = 0) { return GetUInt(Default); }
00773         UInt64 GetUint64(UInt64 Default = 0) { return GetUInt64(Default); }
00774         std::string GetString(std::string Default = "") { if(Value) return Value->GetString(); else return Default; };
00775         bool IsDValue(void);
00776 
00778 
00779         bool SetDefault(void)
00780         {
00781             if(!Value) return false;
00782 
00783             ASSERT(Type);
00784 
00785             if(Type->GetDefault().Size == 0) return false;
00786 
00787             Value->ReadValue(Type->GetDefault());
00788 
00789             return true;
00790         }
00791 
00792 
00793         /* Child value access */
00794         // For set functions AddChild is used (without replace option)
00795         // to ensure that the child exists and to set the modified flag
00796         void SetInt(const char *ChildName, Int32 Val) 
00797         { 
00798             MDObjectPtr Ptr = AddChild(ChildName);
00799             if (Ptr) Ptr->SetInt(Val); 
00800             else if(Value) { SetModified(true); Value->SetInt(ChildName, Val); }
00801         };
00802         void SetInt64(const char *ChildName, Int64 Val) 
00803         { 
00804             MDObjectPtr Ptr = AddChild(ChildName);
00805             if (Ptr) Ptr->SetInt64(Val);
00806             else if(Value) { SetModified(true); Value->SetInt64(ChildName, Val); }
00807         };
00808         void SetUInt(const char *ChildName, UInt32 Val) 
00809         { 
00810             MDObjectPtr Ptr = AddChild(ChildName);
00811             if (Ptr) Ptr->SetUInt(Val);
00812             else if(Value) { SetModified(true); Value->SetUInt(ChildName, Val); }
00813         };
00814         void SetUInt64(const char *ChildName, UInt64 Val) 
00815         { 
00816             MDObjectPtr Ptr = AddChild(ChildName);
00817             if (Ptr) Ptr->SetUInt64(Val);
00818             else if(Value) { SetModified(true); Value->SetUInt64(ChildName, Val); }
00819         };
00820         void SetUint(const char *ChildName, UInt32 Val) { SetUInt(ChildName, Val); }
00821         void SetUint64(const char *ChildName, UInt64 Val) { SetUInt64(ChildName, Val); }
00822 
00823         void SetString(const char *ChildName, std::string Val) 
00824         { 
00825             MDObjectPtr Ptr = AddChild(ChildName);
00826             if (Ptr) Ptr->SetString(Val);
00827             else if(Value) { SetModified(true); Value->SetString(ChildName, Val); }
00828         };
00829 
00830         bool SetDValue(const char *ChildName) 
00831         { 
00832             MDObjectPtr Ptr = AddChild(ChildName); 
00833             if (Ptr) return Ptr->SetDValue(); else return false; 
00834         };
00835         
00836         void SetValue(const char *ChildName, const DataChunk &Source) 
00837         { 
00838             MDObjectPtr Ptr = AddChild(ChildName); 
00839             if (Ptr) Ptr->ReadValue(Source); 
00840             else if(Value) { SetModified(true); Value->ReadValue(ChildName, Source); }
00841         };
00842 
00843         void SetValue(const char *ChildName, MDObjectPtr Source) 
00844         { 
00845             MDObjectPtr Ptr = AddChild(ChildName); 
00846             if (Ptr) Ptr->ReadValue(Source->Value->PutData());
00847             else if(Value) { SetModified(true); Value->ReadValue(ChildName, Source->Value->PutData()); }
00848         };
00849 
00850         Int32 GetInt(const char *ChildName, Int32 Default = 0) 
00851         { 
00852             MDObjectPtr Ptr = operator[](ChildName);
00853             if (Ptr) return Ptr->GetInt(); else if(Value) return Value->GetInt(ChildName, Default); else return Default; 
00854         };
00855 
00856         Int64 GetInt64(const char *ChildName, Int64 Default = 0) 
00857         { 
00858             MDObjectPtr Ptr = operator[](ChildName); 
00859             if (Ptr) return Ptr->GetInt64(); else if(Value) return Value->GetInt64(ChildName, Default); else return Default; 
00860         };
00861 
00862         UInt32 GetUInt(const char *ChildName, UInt32 Default = 0) 
00863         { 
00864             MDObjectPtr Ptr = operator[](ChildName); 
00865             if (Ptr) return Ptr->GetUInt(); else if(Value) return Value->GetUInt(ChildName, Default); else return Default; 
00866         };
00867 
00868         UInt64 GetUInt64(const char *ChildName, UInt64 Default = 0) 
00869         { 
00870             MDObjectPtr Ptr = operator[](ChildName); 
00871             if (Ptr) return Ptr->GetUInt64(); else if(Value) return Value->GetUInt64(ChildName, Default); else return Default; 
00872         };
00873 
00874         UInt32 GetUint(const char *ChildName, UInt32 Default = 0) { return GetUInt(ChildName, Default); }
00875         UInt64 GetUint64(const char *ChildName, UInt64 Default = 0)  { return GetUInt64(ChildName, Default); }
00876 
00877         std::string GetString(const char *ChildName, std::string Default = "")
00878         { 
00879             MDObjectPtr Ptr = operator[](ChildName); 
00880             if (Ptr) return Ptr->GetString(); else if(Value) return Value->GetString(ChildName, Default); else return Default; 
00881         };
00882 
00883         bool IsDValue(const char *ChildName) 
00884         { 
00885             MDObjectPtr Ptr = operator[](ChildName);
00886             if (Ptr) return Ptr->IsDValue(); else return false; 
00887         };
00888 
00889         void SetInt(const UL &ChildType, Int32 Val) 
00890         { 
00891             MDObjectPtr Ptr = AddChild(ChildType);
00892             if (Ptr) Ptr->SetInt(Val);
00893         };
00894         void SetInt(ULPtr &ChildType, Int32 Val) { SetInt(*ChildType, Val); }
00895 
00896         void SetInt64(const UL &ChildType, Int64 Val) 
00897         { 
00898             MDObjectPtr Ptr = AddChild(ChildType);
00899             if (Ptr) Ptr->SetInt64(Val);
00900         };
00901         void SetInt64(ULPtr &ChildType, Int64 Val) { SetInt64(*ChildType, Val); }
00902 
00903         void SetUInt(const UL &ChildType, UInt32 Val) 
00904         { 
00905             MDObjectPtr Ptr = AddChild(ChildType);
00906             if (Ptr) Ptr->SetUInt(Val);
00907         };
00908         void SetUInt(ULPtr &ChildType, UInt32 Val) { SetUInt(*ChildType, Val); }
00909 
00910         void SetUInt64(const UL &ChildType, UInt64 Val) 
00911         { 
00912             MDObjectPtr Ptr = AddChild(ChildType);
00913             if (Ptr) Ptr->SetUInt64(Val);
00914         };
00915         void SetUInt64(ULPtr &ChildType, UInt64 Val) { SetUInt64(*ChildType, Val); }
00916 
00917         void SetString(const UL &ChildType, std::string Val) 
00918         { 
00919             MDObjectPtr Ptr = AddChild(ChildType);
00920             if (Ptr) Ptr->SetString(Val);
00921         };
00922         void SetString(ULPtr &ChildType, std::string Val) { SetString(*ChildType, Val); }
00923 
00924         bool SetDValue(const UL &ChildType) 
00925         { 
00926             MDObjectPtr Ptr = AddChild(ChildType); 
00927             if (Ptr) return Ptr->SetDValue(); else return false;
00928         };
00929         bool SetDValue(ULPtr &ChildType) { return SetDValue(*ChildType); }
00930         
00931         void SetValue(const UL &ChildType, const DataChunk &Source) 
00932         { 
00933             MDObjectPtr Ptr = AddChild(ChildType); 
00934             if (Ptr) Ptr->ReadValue(Source);
00935         };
00936         void SetValue(ULPtr &ChildType, const DataChunk &Source) { SetValue(*ChildType, Source); }
00937 
00938         void SetValue(const UL &ChildType, MDObjectPtr Source) 
00939         { 
00940             MDObjectPtr Ptr = AddChild(ChildType); 
00941             if (Ptr) Ptr->ReadValue(Source->Value->PutData());
00942         };
00943         void SetValue(ULPtr &ChildType, MDObjectPtr Source) { SetValue(*ChildType, Source); }
00944         
00945         Int32 GetInt(const UL &ChildType, Int32 Default = 0)
00946         { 
00947             MDObjectPtr Ptr = operator[](ChildType);
00948             if (Ptr) return Ptr->GetInt(); else return Default;
00949         };
00950         Int32 GetInt(ULPtr &ChildType, Int32 Default = 0) { return GetInt(*ChildType, Default); }
00951 
00952         Int64 GetInt64(const UL &ChildType, Int64 Default = 0) 
00953         { 
00954             MDObjectPtr Ptr = operator[](ChildType); 
00955             if (Ptr) return Ptr->GetInt64(); else return Default;
00956         };
00957         Int64 GetInt64(ULPtr &ChildType, Int64 Default = 0) { return GetInt64(*ChildType, Default); }
00958 
00959         UInt32 GetUInt(const UL &ChildType, UInt32 Default = 0) 
00960         { 
00961             MDObjectPtr Ptr = operator[](ChildType); 
00962             if (Ptr) return Ptr->GetUInt(); else return Default;
00963         };
00964         UInt32 GetUInt(ULPtr &ChildType, UInt32 Default = 0) { return GetUInt(*ChildType, Default); }
00965 
00966         UInt64 GetUInt64(const UL &ChildType, UInt64 Default = 0) 
00967         { 
00968             MDObjectPtr Ptr = operator[](ChildType); 
00969             if (Ptr) return Ptr->GetUInt64(); else return Default;
00970         };
00971         UInt64 GetUInt64(ULPtr &ChildType, UInt64 Default = 0) { return GetUInt64(*ChildType, Default); }
00972 
00973         std::string GetString(const UL &ChildType, std::string Default = "")
00974         { 
00975             MDObjectPtr Ptr = operator[](ChildType); 
00976             if (Ptr) return Ptr->GetString(); else return Default;
00977         };
00978         std::string GetString(ULPtr &ChildType, std::string Default = "") { return GetString(*ChildType, Default); }
00979 
00980         bool IsDValue(const UL &ChildType) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->IsDValue(); else return false; };
00981         bool IsDValue(ULPtr &ChildType) { return IsDValue(*ChildType); }
00982 
00983         void SetInt(MDOTypePtr ChildType, Int32 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetInt(Val); };
00984         void SetInt64(MDOTypePtr ChildType, Int64 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetInt64(Val); };
00985         void SetUInt(MDOTypePtr ChildType, UInt32 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetUInt(Val); };
00986         void SetUInt64(MDOTypePtr ChildType, UInt64 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetUInt64(Val); };
00987         void SetUint(MDOTypePtr ChildType, UInt32 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetUInt(Val); };
00988         void SetUint64(MDOTypePtr ChildType, UInt64 Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetUInt64(Val); };
00989         void SetString(MDOTypePtr ChildType, std::string Val) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->SetString(Val); };
00990         bool SetDValue(MDOTypePtr ChildType) { MDObjectPtr Ptr = AddChild(ChildType); if (Ptr) return Ptr->SetDValue(); else return false; };
00991         void SetValue(MDOTypePtr ChildType, MDObjectPtr Source) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->ReadValue(Source->Value->PutData()); }
00992         void SetValue(MDOTypePtr ChildType, const DataChunk &Source) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) Ptr->ReadValue(Source); }
00993         Int32 GetInt(MDOTypePtr ChildType, Int32 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetInt(); else return Default; };
00994         Int64 GetInt64(MDOTypePtr ChildType, Int64 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetInt64(); else return Default; };
00995         UInt32 GetUInt(MDOTypePtr ChildType, UInt32 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetUInt(); else return Default; };
00996         UInt64 GetUInt64(MDOTypePtr ChildType, UInt64 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetUInt64(); else return Default; };
00997         UInt32 GetUint(MDOTypePtr ChildType, UInt32 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetUInt(); else return Default; };
00998         UInt64 GetUint64(MDOTypePtr ChildType, UInt64 Default = 0) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetUInt64(); else return Default; };
00999         std::string GetString(MDOTypePtr ChildType, std::string Default = "") { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->GetString(); else return Default; };
01000         bool IsDValue(MDOTypePtr ChildType) { MDObjectPtr Ptr = operator[](ChildType); if (Ptr) return Ptr->IsDValue(); else return false; };
01001 
01002         /* Child raw data access */
01004         const DataChunk& GetData(void) { ASSERT(Value); return Value->GetData(); };
01005 
01007         const DataChunkPtr PutData(PrimerPtr UsePrimer = NULL);
01008 
01010         size_t ReadValue(const DataChunk &Chunk) { return ReadValue(Chunk.Data, Chunk.Size); };
01011 
01013         size_t ReadValue(DataChunkPtr &Chunk) { return ReadValue(Chunk->Data, Chunk->Size); };
01014 
01016         size_t ReadValue(const UInt8 *Buffer, size_t Size, PrimerPtr UsePrimer = NULL);
01017 
01019         DataChunkPtr WriteObject(MDObjectPtr ParentObject, PrimerPtr UsePrimer, UInt32 BERSize = 0)
01020         {
01021             DataChunkPtr Ret = new DataChunk;
01022             WriteObject(Ret, ParentObject, UsePrimer, BERSize);
01023             return Ret;
01024         }
01025 
01027         size_t WriteObject(DataChunkPtr &Buffer, MDObjectPtr ParentObject, PrimerPtr UsePrimer, UInt32 BERSize = 0);
01028 
01030 
01033         DataChunkPtr WriteObject(PrimerPtr UsePrimer = NULL, UInt32 BERSize = 0)
01034         {
01035             DataChunkPtr Ret = new DataChunk;
01036             WriteObject(Ret, NULL, UsePrimer, BERSize);
01037             return Ret;
01038         }
01039 
01041 
01044         size_t WriteObject(DataChunkPtr &Buffer, PrimerPtr UsePrimer = NULL, UInt32 BERSize = 0)
01045         {
01046             return WriteObject(Buffer, NULL, UsePrimer, BERSize);
01047         }
01048 
01050         size_t WriteLinkedObjects(DataChunkPtr &Buffer, PrimerPtr UsePrimer = NULL);
01051 
01053         std::string Name(void) const { return ObjectName; };
01054 
01056         std::string FullName(void) const 
01057         {
01058             if(Parent) return Parent->FullName() + "/" + ObjectName;
01059             else return ObjectName; 
01060         };
01061 
01063         void insert(MDObjectPtr NewObject)
01064         {
01065             if(NewObject->TheUL)
01066                 push_back(MDObjectULList::value_type(*(NewObject->TheUL), NewObject));
01067             else
01068                 ASSERT(0);
01069 //              push_back(MDObjectULList::value_type(Null_UL, NewObject));
01070         }
01071 
01073         const MDOTypePtr &GetType(void) const { return Type; };
01074 
01076         bool IsA(std::string BaseType);
01077 
01079         bool IsA(MDOTypePtr &BaseType);
01080         
01082         bool IsA(const UL &BaseType);
01083 
01085         bool IsA(ULPtr &BaseType) { return IsA(*BaseType); }
01086 
01088         MDObjectPtr GetLink(void) const { return Link; };
01089 
01091         bool MakeRef(MDObjectPtr &TargetSet, bool ForceLink = false);
01092     
01094 
01095         bool MakeLink(MDObjectPtr &TargetSet, bool ForceLink = false) { return MakeRef(TargetSet, ForceLink); }
01096     
01098         void SetLink(MDObjectPtr NewLink) { Link = NewLink; };
01099 
01101         ClassRef GetRefType(void) const { ASSERT(Type); return Type->GetRefType(); };
01102 
01104         MDOTypePtr GetRefTarget(void) const { if(Type) return Type->GetRefTarget(); else return NULL; };
01105 
01107         void SetParent(MXFFilePtr &File, UInt64 Location, UInt32 NewKLSize)
01108         {
01109             IsConstructed = false;
01110             ParentOffset = Location;
01111             KLSize = NewKLSize;
01112             Parent = NULL;
01113             ParentFile = File;
01114         }
01115 
01117         void SetParent(MDObjectPtr &Object, UInt64 Location, UInt32 NewKLSize)
01118         {
01119             IsConstructed = false;
01120             ParentOffset = Location;
01121             KLSize = NewKLSize;
01122             Parent = Object;
01123             ParentFile = NULL;
01124         }
01125 
01127         MDObjectParent &GetParent(void) { return Parent; }
01128 
01130         MXFFilePtr &GetParentFile(void) { return ParentFile; };
01131 
01133         const ULPtr &GetUL(void) { return TheUL; }
01134 
01136         void SetUL(ULPtr &NewUL) { TheUL = NewUL; }
01137 
01139         void SetTag(Tag NewTag) { TheTag = NewTag; }
01140 
01142         Tag GetTag(void) { return TheTag; }
01143 
01145 
01146         bool ChangeType(const UL &NewType)
01147         {
01148             MDOTypePtr Ptr = MDOType::Find(NewType);
01149 
01150             if(!Ptr) return false;
01151 
01152             Type = Ptr;
01153             ObjectName = Type->Name();
01154             TheUL = Type->GetUL();
01155             if(TheUL) TheTag = MDOType::GetStaticPrimer()->Lookup(TheUL);
01156             else TheTag = 0;
01157 
01158             return true;
01159         }
01160 
01162 
01163         bool ChangeType(ULPtr &NewType) { return ChangeType(*NewType); }
01164 
01166 
01167         bool ChangeType(std::string NewType)
01168         {
01169             MDOTypePtr Ptr = MDOType::Find(NewType);
01170 
01171             if(!Ptr) return false;
01172 
01173             Type = Ptr;
01174             ObjectName = Type->Name();
01175             TheUL = Type->GetUL();
01176             if(TheUL) TheTag = MDOType::GetStaticPrimer()->Lookup(TheUL);
01177             else TheTag = 0;
01178 
01179             return true;
01180         }
01181 
01183         MDObjectPtr MakeCopy(void);
01184 
01185     protected:
01187 
01190         void SetModified(bool State) { Modified = State; }
01191 
01192     public:
01194 
01197         bool SetGenerationUID(UUIDPtr UID);
01198 
01200         bool IsModified(void);
01201 
01203         void ClearModified(void);
01204 
01206         UInt64 GetLocation(void);
01207 
01209         std::string GetSource(void);
01210 
01212         std::string GetSourceLocation(void) 
01213         {
01214             return std::string("0x") + Int64toHexString(GetLocation(),8) + std::string(" in ") + GetSource();
01215         }
01216 
01218         ObjectInterface *GetOuter(void) { return Outer; };
01219 
01221         void SetOuter(ObjectInterface *NewOuter) { Outer = NewOuter; };
01222 
01223     public:
01225         static void SetULTranslator(ULTranslator Trans) { UL2NameFunc = Trans; }
01226 
01228         static void SetParseDark(bool Value) { ParseDark = Value; }
01229 
01230     protected:
01231         // Some private helper functions
01232         static UInt32 ReadKey(DictKeyFormat Format, size_t Size, const UInt8 *Buffer, DataChunk& Key);
01233         static UInt32 ReadLength(DictLenFormat Format, size_t Size, const UInt8 *Buffer, Length& Length);
01234         UInt32 WriteKey(DataChunkPtr &Buffer, DictKeyFormat Format, PrimerPtr UsePrimer = NULL);
01235         static UInt32 WriteLength(DataChunkPtr &Buffer, Length Length, DictLenFormat Format, UInt32 Size = 0);
01236     };
01237 }
01238 
01239 
01240 namespace mxflib
01241 {
01243 
01246     class ObjectInterface
01247     {
01248     protected:
01250         ObjectInterface(MDObjectPtr BaseObject) : Object(BaseObject) {}
01251 
01252     public:
01253         MDObjectPtr Object;                 
01254 
01255     public:
01256         ObjectInterface() {};               
01257         virtual ~ObjectInterface() {};      
01258         
01259         // ** MDObject Interface **
01260         std::string Name(void) const { return Object->Name(); };
01261         std::string FullName(void) const { return Object->FullName(); };
01262 
01264         MDObjectPtr operator[](std::string ChildName) { return Object->operator[](ChildName); };
01265         MDObjectPtr Child(std::string ChildName) { return Object->operator[](ChildName); };
01266         MDObjectListPtr ChildList(std::string ChildName) { return Object->ChildList(ChildName); };
01267         
01268         MDObjectPtr operator[](const UL &ChildType) { return Object->operator[](ChildType); };
01269         MDObjectPtr Child(const UL &ChildType) { return Object->operator[](ChildType); };
01270         MDObjectListPtr ChildList(const UL &ChildType) { return Object->ChildList(ChildType); };
01271         
01272         MDObjectPtr operator[](ULPtr &ChildType) { return Object->operator[](*ChildType); };
01273         MDObjectPtr Child(ULPtr &ChildType) { return Object->operator[](*ChildType); };
01274         MDObjectListPtr ChildList(ULPtr &ChildType) { return Object->ChildList(*ChildType); };
01275 
01276         MDObjectPtr operator[](MDOTypePtr ChildType) { return Object->operator[](ChildType); };
01277         MDObjectPtr Child(MDOTypePtr ChildType) { return Object->operator[](ChildType); };
01278         MDObjectListPtr ChildList(MDOTypePtr ChildType) { return Object->ChildList(ChildType); };
01279 
01280         MDObjectPtr AddChild(void) { return Object->AddChild(); }
01281         MDObjectPtr AddChild(std::string ChildName, bool Replace = true) { return Object->AddChild(ChildName, Replace); };
01282         MDObjectPtr AddChild(MDObjectPtr ChildObject, bool Replace = false) { return Object->AddChild(ChildObject, Replace); };
01283         MDObjectPtr AddChild(const UL &ChildType, bool Replace = true) { return Object->AddChild(ChildType, Replace); };
01284         MDObjectPtr AddChild(ULPtr &ChildType, bool Replace = true) { return Object->AddChild(*ChildType, Replace); };
01285 
01286         void RemoveChild(std::string ChildName) { Object->RemoveChild(ChildName); };
01287         void RemoveChild(MDOTypePtr ChildType) { Object->RemoveChild(ChildType); };
01288         void RemoveChild(MDObjectPtr ChildObject) { Object->RemoveChild(ChildObject); };
01289 
01290         void SetInt(const char *ChildName, Int32 Val) { Object->SetInt(ChildName, Val); };
01291         void SetInt64(const char *ChildName, Int64 Val) { Object->SetInt64(ChildName, Val); };
01292         void SetUInt(const char *ChildName, UInt32 Val) { Object->SetUInt(ChildName, Val); };
01293         void SetUInt64(const char *ChildName, UInt64 Val) { Object->SetUInt64(ChildName, Val); };
01294         void SetUint(const char *ChildName, UInt32 Val) { Object->SetUInt(ChildName, Val); };
01295         void SetUint64(const char *ChildName, UInt64 Val) { Object->SetUInt64(ChildName, Val); };
01296         void SetString(const char *ChildName, std::string Val) { Object->SetString(ChildName, Val); };
01297         bool SetDValue(const char *ChildName) { return Object->SetDValue(ChildName); };
01298         void SetValue(const char *ChildName, const DataChunk &Source) { Object->SetValue(ChildName, Source); }
01299         void SetValue(const char *ChildName, MDObjectPtr Source) { Object->SetValue(ChildName, Source); }
01300         Int32 GetInt(const char *ChildName, Int32 Default = 0) { return Object->GetInt(ChildName, Default); };
01301         Int64 GetInt64(const char *ChildName, Int64 Default = 0) { return Object->GetInt64(ChildName, Default); };
01302         UInt32 GetUInt(const char *ChildName, UInt32 Default = 0) { return Object->GetUInt(ChildName, Default); };
01303         UInt64 GetUInt64(const char *ChildName, UInt64 Default = 0) { return Object->GetUInt64(ChildName, Default); };
01304         UInt32 GetUint(const char *ChildName, UInt32 Default = 0) { return Object->GetUInt(ChildName, Default); };
01305         UInt64 GetUint64(const char *ChildName, UInt64 Default = 0) { return Object->GetUInt64(ChildName, Default); };
01306         std::string GetString(const char *ChildName, std::string Default = "") { return Object->GetString(ChildName, Default); };
01307         bool IsDValue(const char *ChildName) { return Object->IsDValue(ChildName); };
01308         
01309         void SetInt(const UL &ChildType, Int32 Val) { Object->SetInt(ChildType, Val); };
01310         void SetInt(ULPtr &ChildType, Int32 Val) { Object->SetInt(*ChildType, Val); };
01311         void SetInt64(const UL &ChildType, Int64 Val) { Object->SetInt64(ChildType, Val); };
01312         void SetInt64(ULPtr &ChildType, Int64 Val) { Object->SetInt64(*ChildType, Val); };
01313         void SetUInt(const UL &ChildType, UInt32 Val) { Object->SetUInt(ChildType, Val); };
01314         void SetUInt(ULPtr &ChildType, UInt32 Val) { Object->SetUInt(*ChildType, Val); };
01315         void SetUInt64(const UL &ChildType, UInt64 Val) { Object->SetUInt64(ChildType, Val); };
01316         void SetUInt64(ULPtr &ChildType, UInt64 Val) { Object->SetUInt64(*ChildType, Val); };
01317         void SetString(const UL &ChildType, std::string Val) { Object->SetString(ChildType, Val); };
01318         void SetString(ULPtr &ChildType, std::string Val) { Object->SetString(*ChildType, Val); };
01319         bool SetDValue(const UL &ChildType) { return Object->SetDValue(ChildType); };
01320         bool SetDValue(ULPtr &ChildType) { return Object->SetDValue(*ChildType); };
01321         void SetValue(const UL &ChildType, const DataChunk &Source) { Object->SetValue(ChildType, Source); }
01322         void SetValue(ULPtr &ChildType, const DataChunk &Source) { Object->SetValue(*ChildType, Source); }
01323         void SetValue(const UL &ChildType, MDObjectPtr Source) { Object->SetValue(ChildType, Source); }
01324         void SetValue(ULPtr &ChildType, MDObjectPtr Source) { Object->SetValue(*ChildType, Source); }
01325         Int32 GetInt(const UL &ChildType, Int32 Default = 0) { return Object->GetInt(ChildType, Default); };
01326         Int32 GetInt(ULPtr &ChildType, Int32 Default = 0) { return Object->GetInt(*ChildType, Default); };
01327         Int64 GetInt64(const UL &ChildType, Int64 Default = 0) { return Object->GetInt64(ChildType, Default); };
01328         Int64 GetInt64(ULPtr &ChildType, Int64 Default = 0) { return Object->GetInt64(*ChildType, Default); };
01329         UInt32 GetUInt(const UL &ChildType, UInt32 Default = 0) { return Object->GetUInt(ChildType, Default); };
01330         UInt32 GetUInt(ULPtr &ChildType, UInt32 Default = 0) { return Object->GetUInt(*ChildType, Default); };
01331         UInt64 GetUInt64(const UL &ChildType, UInt64 Default = 0) { return Object->GetUInt64(ChildType, Default); };
01332         UInt64 GetUInt64(ULPtr &ChildType, UInt64 Default = 0) { return Object->GetUInt64(*ChildType, Default); };
01333         std::string GetString(const UL &ChildType, std::string Default = "") { return Object->GetString(ChildType, Default); };
01334         std::string GetString(ULPtr &ChildType, std::string Default = "") { return Object->GetString(*ChildType, Default); };
01335         bool IsDValue(const UL &ChildType) { return Object->IsDValue(ChildType); };
01336         bool IsDValue(ULPtr &ChildType) { return Object->IsDValue(*ChildType); };
01337 
01338         void SetInt(MDOTypePtr ChildType, Int32 Val) { Object->SetInt(ChildType, Val); };
01339         void SetInt64(MDOTypePtr ChildType, Int64 Val) { Object->SetInt64(ChildType, Val); };
01340         void SetUInt(MDOTypePtr ChildType, UInt32 Val) { Object->SetUInt(ChildType, Val); };
01341         void SetUInt64(MDOTypePtr ChildType, UInt64 Val) { Object->SetUInt64(ChildType, Val); };
01342         void SetUint(MDOTypePtr ChildType, UInt32 Val) { Object->SetUInt(ChildType, Val); };
01343         void SetUint64(MDOTypePtr ChildType, UInt64 Val) { Object->SetUInt64(ChildType, Val); };
01344         void SetString(MDOTypePtr ChildType, std::string Val) { Object->SetString(ChildType, Val); };
01345         bool SetDValue(MDOTypePtr ChildType) { return Object->SetDValue(ChildType); };
01346         void SetValue(MDOTypePtr ChildType, const DataChunk &Source) { Object->SetValue(ChildType, Source); }
01347         void SetValue(MDOTypePtr ChildType, MDObjectPtr Source) { Object->SetValue(ChildType, Source); }
01348         Int32 GetInt(MDOTypePtr ChildType, Int32 Default = 0) { return Object->GetInt(ChildType, Default); };
01349         Int64 GetInt64(MDOTypePtr ChildType, Int64 Default = 0) { return Object->GetInt64(ChildType, Default); };
01350         UInt32 GetUInt(MDOTypePtr ChildType, UInt32 Default = 0) { return Object->GetUInt(ChildType, Default); };
01351         UInt64 GetUInt64(MDOTypePtr ChildType, UInt64 Default = 0) { return Object->GetUInt64(ChildType, Default); };
01352         UInt32 GetUint(MDOTypePtr ChildType, UInt32 Default = 0) { return Object->GetUInt(ChildType, Default); };
01353         UInt64 GetUint64(MDOTypePtr ChildType, UInt64 Default = 0) { return Object->GetUInt64(ChildType, Default); };
01354         std::string GetString(MDOTypePtr ChildType, std::string Default = "") { return Object->GetString(ChildType, Default); };
01355         bool IsDValue(MDOTypePtr ChildType) { return Object->IsDValue(ChildType); };
01356 
01358         const DataChunk& GetData(void) { ASSERT(Object); return Object->GetData(); };
01359 
01361         DataChunkPtr PutData(PrimerPtr UsePrimer = NULL) { if(Object) return Object->PutData(UsePrimer); else return new DataChunk(); };
01362 
01364         size_t ReadValue(const DataChunk &Chunk) { return Object->ReadValue(Chunk.Data, Chunk.Size); };
01365 
01367         size_t ReadValue(const DataChunkPtr &Chunk) { return Object->ReadValue(Chunk->Data, Chunk->Size); };
01368 
01370         size_t ReadValue(const UInt8 *Buffer, size_t Size, PrimerPtr UsePrimer = NULL) { return Object->ReadValue(Buffer, Size, UsePrimer); };
01371 
01373         DataChunkPtr WriteObject(MDObjectPtr ParentObject, PrimerPtr UsePrimer) { return Object->WriteObject(ParentObject, UsePrimer); };
01374 
01376         size_t WriteObject(DataChunkPtr &Buffer, MDObjectPtr ParentObject, PrimerPtr UsePrimer) { return Object->WriteObject(Buffer, ParentObject, UsePrimer); };
01377 
01379 
01382         DataChunkPtr WriteObject(PrimerPtr UsePrimer = NULL)
01383         {
01384             return Object->WriteObject(NULL, UsePrimer);
01385         }
01386 
01388 
01391         size_t WriteObject(DataChunkPtr &Buffer, PrimerPtr UsePrimer = NULL)
01392         {
01393             return Object->WriteObject(Buffer, NULL, UsePrimer);
01394         }
01395 
01396         MDOTypePtr GetType(void) const { return Object->GetType(); };
01397         MDObjectPtr GetLink(void) const { return Object->GetLink(); };
01398         void SetLink(MDObjectPtr NewLink) { Object->SetLink(NewLink); };
01399         ClassRef GetRefType(void) const { return Object->GetRefType(); };
01400 
01402         bool IsA(std::string BaseType) { return Object->IsA(BaseType); }
01403 
01405         bool IsA(MDOTypePtr BaseType) { return Object->IsA(BaseType); }
01406 
01408         bool IsA(const UL &BaseType) { return Object->IsA(BaseType); }
01409 
01411         bool IsA(ULPtr &BaseType) { return Object->IsA(*BaseType); }
01412 
01414         void SetParent(MXFFilePtr File, UInt64 Location, UInt32 NewKLSize) { Object->SetParent(File, Location, NewKLSize); };
01415 
01417         void SetParent(MDObjectPtr ParentObject, UInt64 Location, UInt32 NewKLSize) { Object->SetParent(ParentObject, Location, NewKLSize); };
01418 
01419         bool IsModified(void) { return Object->IsModified(); }
01420 
01422         void ClearModified(void) { Object->ClearModified(); }
01423 
01424         UInt64 GetLocation(void) { return Object->GetLocation(); }
01425         std::string GetSource(void) { return Object->GetSource(); }
01426         std::string GetSourceLocation(void) { return Object->GetSourceLocation(); }
01427 
01429 
01430         bool ChangeType(std::string NewType) { return Object->ChangeType(NewType); };
01431 
01433 
01434         bool ChangeType(const UL &NewType) { return Object->ChangeType(NewType); }
01435 
01437 
01438         bool ChangeType(ULPtr &NewType) { return Object->ChangeType(*NewType); }
01439 
01440     };
01441 }
01442 
01443 
01444 // These simple inlines need to be defined after MDObject
01445 namespace mxflib
01446 {
01447 inline MDObjectPtr MDObjectPtr::operator[](const char *ChildName) { return GetPtr()->operator[](ChildName); }
01448 inline MDObjectPtr MDObjectPtr::operator[](MDOTypePtr &ChildType) { return GetPtr()->operator[](ChildType); }
01449 inline MDObjectPtr MDObjectPtr::operator[](const UL &ChildType) { return GetPtr()->operator[](ChildType); }
01450 inline MDObjectPtr MDObjectPtr::operator[](ULPtr &ChildType) { return GetPtr()->operator[](ChildType); }
01451 inline MDObjectPtr MDObjectParent::operator[](const char *ChildName) { return GetPtr()->operator[](ChildName); }
01452 inline MDObjectPtr MDObjectParent::operator[](MDOTypePtr &ChildType) { return GetPtr()->operator[](ChildType); }
01453 inline MDObjectPtr MDObjectParent::operator[](const UL &ChildType) { return GetPtr()->operator[](ChildType); }
01454 inline MDObjectPtr MDObjectParent::operator[](ULPtr &ChildType) { return GetPtr()->operator[](ChildType); }
01455 }
01456 
01457 #endif // MXFLIB__MDOBJECT_H

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