release
[asdcplib.git] / src / KLV.h
index 587bbe8315a79b3c465ddd8964b82a5d985e6535..9eb230b6d91c663285158ecfa7ae6c65a65d4cd6 100755 (executable)
--- a/src/KLV.h
+++ b/src/KLV.h
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005, John Hurst
+Copyright (c) 2005-2006, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -24,13 +24,18 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
+/*! \file    KLV.h
+  \version $Id$
+  \brief   KLV objects
+*/
 
 #ifndef _KLV_H_
 #define _KLV_H_
 
-#include <FileIO.h>
-#include <MemIO.h>
+#include "FileIO.h"
+#include "MemIO.h"
+#include "MDD.h"
+
 
 namespace ASDCP
 {
@@ -66,8 +71,9 @@ namespace ASDCP
     {
     public:
       virtual ~IArchive() {}
-      virtual Result_t ReadFrom(ASDCP::MemIOReader& Reader) = 0;
-      virtual Result_t WriteTo(ASDCP::MemIOWriter& Writer) = 0;
+      virtual Result_t Unarchive(ASDCP::MemIOReader& Reader) = 0;
+      virtual bool     HasValue() const = 0;
+      virtual Result_t Archive(ASDCP::MemIOWriter& Writer) const = 0;
     };
 } // namespace ASDCP
 
@@ -75,16 +81,6 @@ namespace ASDCP
 
 namespace ASDCP
 {
-  //
-  class IPrimerLookup
-    {
-    public:
-      virtual ~IPrimerLookup() {}
-      virtual void     ClearTagList() = 0;
-      virtual Result_t InsertTag(const ASDCP::UL& Key, ASDCP::TagValue& Tag) = 0;
-      virtual Result_t TagForKey(const ASDCP::UL& Key, ASDCP::TagValue& Tag) = 0;
-    };
-
   //
   struct MDDEntry
   {
@@ -92,11 +88,43 @@ namespace ASDCP
     TagValue      tag;
     bool          optional;
     const char*   name;
-    const char*   detail;
   };
 
   //
-  const MDDEntry* GetMDDEntry(const byte_t*);
+  class Dict
+    {
+    public:
+      static const MDDEntry* FindUL(const byte_t*);
+      static const MDDEntry* FindName(const char*);
+      static const MDDEntry& Type(MDD_t type_id);
+      static bool            Replace(const MDDEntry& Entry);
+      static void            Restore(const byte_t* ul);
+      static void            RestoreAll();
+
+      inline static const byte_t* ul(MDD_t type_id) {
+       return Type(type_id).ul;
+      }
+
+    private:
+      Dict* m_Dict;
+      ASDCP_NO_COPY_CONSTRUCT(Dict);
+
+    protected:
+      Dict();
+
+    public:
+      ~Dict();
+    };
+
+  //
+  class IPrimerLookup
+    {
+    public:
+      virtual ~IPrimerLookup() {}
+      virtual void     ClearTagList() = 0;
+      virtual Result_t InsertTag(const MDDEntry& Entry, ASDCP::TagValue& Tag) = 0;
+      virtual Result_t TagForKey(const ASDCP::UL& Key, ASDCP::TagValue& Tag) = 0;
+    };
 
   //
   class KLVPacket