primer.h

Go to the documentation of this file.
00001 
00011 /*
00012  *  Copyright (c) 2003, Matt Beard
00013  *
00014  *  This software is provided 'as-is', without any express or implied warranty.
00015  *  In no event will the authors be held liable for any damages arising from
00016  *  the use of this software.
00017  *
00018  *  Permission is granted to anyone to use this software for any purpose,
00019  *  including commercial applications, and to alter it and redistribute it
00020  *  freely, subject to the following restrictions:
00021  *
00022  *    1. The origin of this software must not be misrepresented; you must
00023  *       not claim that you wrote the original software. If you use this
00024  *       software in a product, an acknowledgment in the product
00025  *       documentation would be appreciated but is not required.
00026  *  
00027  *    2. Altered source versions must be plainly marked as such, and must
00028  *       not be misrepresented as being the original software.
00029  *  
00030  *    3. This notice may not be removed or altered from any source
00031  *       distribution.
00032  */
00033 #ifndef MXFLIB__PRIMER_H
00034 #define MXFLIB__PRIMER_H
00035 
00036 #include <mxflib/mdtype.h>
00037 
00038 
00039 #include <map>
00040 
00041 namespace mxflib
00042 {
00043     // Forward declare so the class can be used
00044     class Primer;
00045 
00047     typedef SmartPtr<Primer> PrimerPtr;
00048 
00050     typedef std::list<PrimerPtr> PrimerList;
00051 }
00052 
00053 
00054 namespace mxflib
00055 {
00056     // Required to make MSVC compile!
00057     typedef std::map<Tag, UL> Primer_Root;
00058 
00060     class Primer : public Primer_Root, public RefCount<Primer>
00061     {
00062     protected:
00063         Tag NextDynamic;                        
00064         std::map<UL, Tag> TagLookup;            
00065 
00066     public:
00067         Primer() { NextDynamic = 0xffff; };
00068         UInt32 ReadValue(const UInt8 *Buffer, UInt32 Size);
00069 
00071         UInt32 WritePrimer(DataChunkPtr &Buffer);
00072 
00074         Tag Lookup(ULPtr ItemUL, Tag TryTag = 0);
00075 
00077         static Tag StaticLookup(ULPtr ItemUL, Tag TryTag = 0);
00078 
00080         std::pair<iterator, bool> insert(value_type Val) 
00081         { 
00082             TagLookup.insert(std::map<UL, Tag>::value_type(Val.second, Val.first));
00083             return Primer_Root::insert(Val);
00084         }
00085     };
00086 }
00087 
00088 #endif // MXFLIB__PRIMER_H

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